Thursday, April 30, 2009

User Id Updating

I am debugging a save
debug($this->User->save($this->data[$model_table], true,
array_keys($this->User->$join_table->schema())));

Everything is working fine in regards to the save except in the debug array
I see User id...and in the SQL log I see

UPDATE `users` SET `id` = 3 WHERE `users`.`id` = 3

Array
(
[User] => Array
(
[id] => 3
)

[System] => Array
(
[0] => 3
[1] => 5
[2] => 4
[3] => 6
[4] => 1
[5] => 2
[6] => 3
[7] => 5
[8] => 4
[9] => 6
[10] => 1
[11] => 2
)

)
I have nothing in the controller relating to the User.id except
$this->User->id = $this->Auth->user('id');
$this->set('user', $this->User->read('id', $this->Auth->user('id')));

Why is updatng? Any ideas?

thanks

Dave


--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Save fields

Question about selecting fields allowed to have data saved to with a HABTM save.
 
I have a users_systems table which has id, user_id, system_id and a form to update the users systems only...no other data.
 
Now I do not want a User attempting to edit the form and edit other data thats saved in the database by adding a data[User][group_id] text field or anything.
 
The code below i added which gets a list of the tables in the database i am going to be saving to, in this case its the users_systems table. So i debug and sure enough i see the 3 fields id, user_id, system_id.
 
Are the fields in the save() function in addition to the User->$join_table or if you leave it blank only fields in the User->$join_table->can be saved to?
 
Basically I want to restrict data being saved exclusively to the fields in the User->$join_table and no where else.
 
But its still saving data to the User table when I add a text field using firebug to the database. How can I only allow data to be saved to the fields in the users_systems table? Using AJAX so Security Component is of no use I guess.
 
 
// this seems to do nothing as i can save other fields by adding a text field manually with firebug to save user entered data.
$whitelist = array('system_id');
        debug(array_intersect(array_keys($this->User->$join_table->schema()), $whitelist));
                          $this->User->save($this->data, true, array_intersect(array_keys($this->User->$join_table->schema()), $whitelist));
 
Ideas?
 
Dave

--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Re: Eine Frage zu Tabellen Relationen( Error 1054)

Hallo Marcus,

Auf dieser Mailingliste wird leider nur Englisch gesprochen. Versuch
es entweder auf der deutschen CakePHP Mailingliste (http://
groups.google.com/group/cakephp-de) oder poste deine Frage nochmal auf
Englisch neu.

-David

On 30 Apr., 18:59, amarradi <radis...@googlemail.com> wrote:
> Hallo zusammen,
>
> ich habe 2 Tabellen mit folgendem Aufbau
>
> Tabelle 1
>
> masterdata
>
> enthält folgende Felder id, vname, vstrasse, vpostleitzahl, vort,
> vgericht, vmitglieder, vgenrenummer, vgenre,vansprechpartner
>
> Tabelle 2
>
> contacts
>
> enthält folgende Felder id canrede, ctitel, cvorname, cname, cstrasse,
> cpostleitzahl, cort, ctelefon, cfax
>
> Die Idee ist die das jedem Eintrag der masterdata(Vereinsliste) genau
> ein Ansprechpartner zugeordnet ist.
> Sozusagen eine hasOne beziehung
>
> mein masterdata Model sieht folgendermaßen aus
>
> class Masterdatum extends AppModel {
>
>         var $name = 'Masterdatum';
>         var $hasOne = array('Contact');
>
> }
>
> mein contact Model sieht so aus
>
> class Contact extends AppModel {
>
>         var $name = 'Contact';
>
> }
>
> Welche Änderungen muss ich an meinem Controller Vornehmen, das es auch
> so funktioniert. Zur Zeit bekomme ich einen SQL Fehler 1054 und einen
> Fehler in der foeach-Schleife der index und view.ctp
> Das cakePHP Framework ist das aktuelle 1.2.2.8120.
>
> Kann mir diesbezüglich jemand helfen, denn die Anleitung im cakebook
> sind dahingehend irgendwie nicht weit genug. Hat jemand eine gute
> Anleitung wie man einfach solche Beziehungen aufbaut und versteht. Das
> ist zur Zeit mein größtes Problem. Danke jetzt schon mal
>
> Viele Grüße
>
> Marcus Radisch
--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Re: Buggy radio buttons using Form Helper?

Check the test cases, hopefully there is one that covers your issues.
If not, add one and submit a ticket. Drop by #cakephp if you want to
discuss. Happy Baking. -GwooBot :)
--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Re: ACL from View

Faza, appreciate the help. The problem I see with your approach occurs
in your earlier example here:
>>in view i put this: (yes, I will make a helper to do it one day)
if (in_array($session->read('Auth.User.group'), array("Administrator",
"Designer"))
{
...

}

This assumes (hard-coded in the view) that group "Designer" will
always have access to this particular view item. If you remove the
right from the designer group, but the logged in user is still a
member of group "Designer" then the condition will still pass. It's
only checking group membership, not the rights of that group (really,
the effective rights of the user is what should be checked) to that
particular action in the view.

What I want is a way, from the view, is to check if the logged-in user
has access to a particular controller/action pair, so that I can show
or hide links to any clickable link.
--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Re: Missing table for missing model

Clear your cache in your tmp folder.
--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

htacces issue

Hi, i've installed cake in two servers, two different applications,
never had a trouble installing and firing it up.

Suddendly I've installed this copy of cake php in a third
server...htaccess trouble. I've activated mod_rewrite and tested the
installation. And this error appears :

Not Found
The requested URL /home/user/public_html/application/app/webroot was
not found in the server

When the cake application IS in fact installed in /home/user/
public_html/application.

I've searched the group and the internet for an answer to this (in the
other two servers I've had to activate mod_rewrite only to made cake
work).

--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Re: Memory Limit Exhausted

Okay... Forget this. I used the paginator helper :D

On 30 Apr., 22:13, "Benedikt R." <bened...@rossgardt.de> wrote:
> But how does this happen?
>
> Doesn't CakePHP recieve the data via an MySQL-Request? How could the
> memory limit be reached?
--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Validate HABTM

I have tried figuring this out on my own to no avail.
 
Where do I validate data being saved into a HABTM table? I have
USERS:
id
 
SYSTEMS:
id
name
 
USERS_SYSTEMS:
id
user_id
system_id
 
I created a simple form for the User to update their Systems but where is validation for this? Do I validate system_id in system model? Do I make a user_systems model and set a validation rule for system_id and user_id there? There is no system_id in the system model so it makes no sense to me to put it in there.  I made a user_systems model and put
var $validate = array(
  'system_id' => array('rule' => array('minLength', 8)) //min 8 just to check if it works as there are only single digit values in db
 );
but it still saves so I am at a loss....
 
Can someone point out what model do I use to validate the HABTM data being saved to the HABTM table?
 
thanks
 
Dave

--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

404 File not found when try to browse my first project

Here is the background.
- cakePHP 1.2 in Linux with Apache
- everything was extract to /root/cakePHP
- when I browse http://localhost/cakePHP, it shows the first page
correctly (CSS, tmp writable, DB connected.)

I establish my first project by creating files (in Dreamweaver) and
store them in app/controllers/books_controller.php and app/views/books/
index.ctp to just display simple text "THIS IS A TEST".

I've got error when I browse to http://localhost/cakePHP/books/. The
error is just normal HTML 404 file not found. I guess I miss some
setup, didn't I?

--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Re: Memory Limit Exhausted

But how does this happen?

Doesn't CakePHP recieve the data via an MySQL-Request? How could the
memory limit be reached?

--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Re: Missing table for missing model

I had that error as well. Unfortunately I don't specifically remember
how I fixed it other than the things you already tried. I remember it
was definitely something I had put in as custom code, (IE.. walking
through associations in another controller).

The way I found it was using the backtrace of the error message, it
gives you the exit point in your app asking for the session table/
model.

Nick

On Apr 30, 7:08 am, forrestgump <vikhya...@gmail.com> wrote:
> Has no one a solution? :(
>
> On Apr 29, 9:10 pm, forrestgump <vikhya...@gmail.com> wrote:
>
> > Hey Faifas,
> > Yes i have....what is even more amusing is that...i put back the
> > Seasons table, but there is no Mode,View or controller for it(i
> > deleted them)....and the app seems to be running...
>
> > Cheers2u2,
> > Forrestgump
>
> > On Apr 29, 7:42 pm, Aivaras <faifas1...@gmail.com> wrote:
>
> > > Hey,
>
> > > did you remove associations in your other models?
>
> > > Cheers,
> > > Faifas
>
> > > On Wed, Apr 29, 2009 at 17:32, forrestgump <vikhya...@gmail.com> wrote:
>
> > > > hey guys,
> > > >  Iam working on a cakephp app and i ran into this problem, though
> > > > minor it is driving me crazy....
> > > > I had created a complete MVC structure for a "Seasons" module, then i
> > > > voted against it and deleted everything related to it..the
> > > > model,views,controller and the table too...
>
> > > > but, my app now keeps giving me an error
>
> > > > Missing Database Table
> > > > Error: Database table seasons for model Season was not found.
>
> > > > Notice: If you want to customize this error message, create app\views
> > > > \errors\missing_table.ctp
>
> > > > Can someone help me resolve this....I tried deleting the necessary
> > > > files in
> > > > ...\app\tmp\cache\models
> > > > ...\app\tmp\cache\persistent
> > > > but still no change....
>
> > > > Will really appreciate all the help u have to offer..
>
> > > > Regards,
> > > > Forrestgump
--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Re: Compare Array - GOT IT!

You can set validation as numeric, AS WELL as your own custom
validation, Cake will let you do that. You create a function that
checks the values (comparing to the DB in your case), and if it's not
valid, your custom validation method simply returns false, and Cake's
validation mechanism takes over, providing whatever textual feedback
is necessary to the user (if any). I'm not entirely sure if you want
or need this, but I thought I'd let you know in case you aren't
already using it.

On Apr 30, 11:58 am, "Dave Maharaj :: WidePixels.com"
<d...@widepixels.com> wrote:
> Yes... the goal is to secure the form (the checkbox values) so an end user
> can not modify the values and submit...All values submitted are checked
> against possible values in the db...so if they don't exist we know someone
> was messing with the form. So that's all done and working.... then it was
> just a matter of selecting the fields that were allowed to have data saved
> to them so if a user tried to add text field or something to the form it
> would not save that 'extra' data.
>
> The validation is set ('numeric') since its a HABTM table its saving id,
> user id , program_id
>
> That was all...sorry for the confusion
>
> Dave  
>
>
>
> -----Original Message-----
> From: Brendon Kozlowski [mailto:Brendon...@hotmail.com]
> Sent: April-30-09 11:48 AM
> To: CakePHP
> Subject: Re: Compare Array - GOT IT!
>
> Ah, okay I understand what you mean now.  It looks like you're doing this in
> the model; am I correct on that?  It should probably be set as a custom
> validation for the particular field(s) you are concerned about.  Since you
> didn't paste all of your code (you don't need to) I'll just hope that's what
> you're doing. :)  If not, you can find that information in the cookbook:http://book.cakephp.org/view/150/Custom-Validation-Rules
>
> If you're not already, you may also want to use the Security Component.
>
> On Apr 29, 10:11 pm, "Dave Maharaj :: WidePixels.com"
> <d...@widepixels.com> wrote:
> > No no...not giving them the ability to edit the form...install Firebug
> > and anyone can edit a form...I am trying to prevent them from editing the
> form.
>
> > I can see the form and use firebug to see the vales in the form
> > checkboxes...value = 1 =3 = so on..... I can change the values with
> > Firebug to 599 799 899 or what ever ...so what I am doing is verify
> > that if someone is being cleaver and changes the values to something
> > that it could not possably be then it will not save anything and the
> > logged in users account is supspended because the ony way the form
> > would not save is if someone was messing with it and submited bad
> > data.(the form is only checkboxes)
>
> > -----Original Message-----
> > From: Brendon Kozlowski [mailto:Brendon...@hotmail.com]
> > Sent: April-29-09 11:15 PM
> > To: CakePHP
> > Subject: Re: Compare Array - GOT IT!
>
> > I don't believe this is necessary in the first place.  Why are you
> > giving someone the ability to edit the form that shouldn't be?  That's
> > the first issue I see.  Secondly, why are you passing values to be
> > saved if you don't want them overwritten?  That's the 2nd issue.
> > Thirdly, why are you even rendering them as form elements rather than
> > simple text within a paragraph tag instead?  That'd be the third issue I
> see.
>
> > Although you are accomplishing what you want to do, I don't believe
> > you should be trying to do it in the first place as a more elegant
> > (albeit possibly more difficult to grasp?) solution is available.
>
> > On Apr 29, 4:52 pm, "Dave Maharaj :: WidePixels.com"
> > <d...@widepixels.com> wrote:
> > > I figured it out.
>
> > > //list of possible keys
> > >                                  $keys =
> > > $this->User->$model_name->find('list', array('fields' => 'id', 'order'
> > > => 'id ASC'));
> > >                                  debug($keys);
>
> > >                                 $submitted =
> > > $this->data[$model_name][$model_name];
>
> > > debug($this->data[$model_name][$model_name]);
>
> > >                                 $results = array_diff($submitted,
> > > $keys);
> > >                                 debug($results);
>
> > > So if a "evil" user tries to change the value in a form and submits,
> > > the value is checked against possible values in the databsae....if
> > > not found we know someone was doing something they should not have been
> doing.
>
> > > I am using this for a form that only has checkboxes so it works for me.
>
> > > Any flaws?
>
> > > Thanks,
>
> > > Dave
>
> > > -----Original Message-----
> > > From: Dave Maharaj :: WidePixels.com [mailto:d...@widepixels.com]
> > > Sent: April-29-09 6:14 PM
> > > To: cake-php@googlegroups.com
> > > Subject: re: Compare Array
>
> > > I am trying to do the same type thing with comparing an array. I am
> > > using this for a security set up so a user can not change values of
> > > a form so I get the list of possible keys
>
> > > //list of possible keys
> > >      $keys = $this->User->$model_name->find('list', array('fields'
> > > => 'id', 'order' => 'id ASC'));
> > >      debug($keys);
>
> > > Array
> > > (
> > >     [1] => 1
> > >     [2] => 2
> > >     [3] => 3
> > >     [4] => 4
> > >     [5] => 5
> > >     [6] => 6
> > > )
>
> > >     // values submitted by user
> > >     $submitted =  $this->data[$model_name][$model_name];
> > >     debug($this->data[$model_name][$model_name]);
>
> > > Array
> > > (
> > >     [0] => 3
> > >     [1] => 5
> > >     [2] => 6
> > >     [3] => 1
> > > )
>
> > >         //how to compare vales against submitted values?
> > >     $results = array_udiff_assoc($keys, array($submitted));
> > >     debug($results);
>
> > > But i need to compare the keys with the submitted data and that
> > > where i am stuck. I need to check that the submitted values have a
> > > match with the possible values in the database.
>
> > > Can someone point out my error or suggestions?
>
> > > Thanks,
>
> > > Dave- Hide quoted text -
>
> > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Re: Is this even possible in cake? (model associations with unknown models)

Have you tried using bindModel() (I think that's what it's called)
with dynamic names? That might work...

However, I'm not sure why this is necessary - If you know enough about
the page to widget relations to serialise it in an array, surely you
know enough to do the same things with a proper DB relation?

On Apr 30, 4:54 pm, Evert <Compa...@gmail.com> wrote:
> My site is build with a lot of plugins.
> Now, I used to use a 'pages' table that had the column called
> 'widgets'
> the column contained a serialized array which contained information
> about which widgets (models) should be in that page. Something like
> this:
>
> array(
>     [0] => array(
>         'name' => 'content'
>         'args' => array(
>             'id' => 1
>         )
>     )
>     [1] => array(
>         'name' => 'comments'
>         'args' => array(
>             'group_id' => 1
>         )
>     )
> )
>
> Then I had plugin-models called 'Content' and 'Comments' which had
> tables like 'content_data', 'content_settings', 'comments_data' and
> 'comments_settings'.
>
> Now someone told me I should never ever have an array inside a
> database-table.
> So I tried to do it without an array, and got up with this database
> structure:
>
> A table called 'pages'
> A table called 'widgets' with columns called 'id' and 'page_id'
> And all my widgets ('content_data' and 'comments_data') got an extra
> column called 'widget_id'
>
> Now I wanted to give my widgets a
> var $belongsTo = array('widgets');
>
> But I can't give my 'widgets'-model a
> var $hasMany = array(?);
> Cause I don't know which widgets are on a page.
> Of course, I could try to associate it with EVERY widget (although I
> wouldn't know how), but that would be very slow when I get a lot of
> widgets.
>
> So, how do I give it the right $hasMany-var?
--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

RE: Value from Key

Its all good.... no worries.
 
I learned something so no matter how it was written or what not, thanks.
 
Bake on!
 
Dave


From: Aivaras [mailto:faifas1337@gmail.com]
Sent: April-30-09 3:13 PM
To: cake-php@googlegroups.com
Subject: Re: Value from Key

I see that You are offended by my last e-mail and for that I offer my humble apologies.

I am not a professional PHP guru and I truly agree with You. Once you make an error you learn from it.
Don't get my opinion wrong, I was also criticized by few cakePHP gurus even tho I do know PHP quite well and I know *how* it *hurts* ;)

Peace,
Faifas

On Thu, Apr 30, 2009 at 19:30, Dave Maharaj :: WidePixels.com <dave@widepixels.com> wrote:
Thanks for the tip...but you can keep your comments to yourself. If i ask a question and make a mistake im glad to those who point it out but you can keep your critiques to yourself. Maybe I am not a professional PHP guru such as yourself but the way you learn is from mistakes.
 
 


From: Aivaras [mailto:faifas1337@gmail.com]
Sent: April-30-09 1:55 PM

To: cake-php@googlegroups.com
Subject: Re: Value from Key

count($results) ?

You surely need to study PHP just a little bit more before diving into a framework :')

Faifas


On Thu, Apr 30, 2009 at 19:06, Dave Maharaj :: WidePixels.com <dave@widepixels.com> wrote:
Thanks to everyone,
 
What i did was:
 
<?php
$i = 0;
  foreach ($results as $error) :
        $i = $i++;
?>
<li><?php  echo $error ;?></li>
<?php endforeach; ?>
 
Its just for tracking a user actions on my site....so if they do something they should not be doing such as messing with the URL  or links/forms  with Firebug it saves the 'bad' info they tried changing it to , where they tied changing it to in a db, and I get a report of who was doing stuff they should not be doing. So thats why the number can change..if they added 5 text fields in a form using Firebug or something i see the 5 fields they added and what they tried to submit.


From: Aivaras [mailto:faifas1337@gmail.com]
Sent: April-30-09 5:06 AM

To: cake-php@googlegroups.com
Subject: Re: Value from Key

for($i = 0; $i < count($array); $i++){
   echo $array[$i]; // will output your error
   echo $i; // will output the index.
}

Still, I have absolutely no idea why would you need to know indexes for error reporting.

Faifas


On Thu, Apr 30, 2009 at 02:30, Dave Maharaj :: WidePixels.com <dave@widepixels.com> wrote:
Right but the [0] [1] will change depending on the array its self.
 
I do not know the number that will be generated as it could be an  array of errors.
 
If there is 1 error [0] but if 10 errors?
 
Ideas?


From: Aivaras [mailto:faifas1337@gmail.com]
Sent: April-29-09 7:42 PM
To: cake-php@googlegroups.com
Subject: Re: Value from Key

Hey,

echo $the_variable_you_are_pr_ing[$key]

example: echo $aNonsenceLetters[0]; // outputs: jkl

Cheers,
Faifas


On Thu, Apr 30, 2009 at 00:47, Dave Maharaj :: WidePixels.com <dave@widepixels.com> wrote:

How can i get the value of a key?

the array is from debug($requests);
for example my array is:

Array
(
   [0] => jkl
   [1] => ii
   [2] => yyy
)
thanks,

Dave










--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Re: Memory Limit Exhausted

likely your php config memory limit is being used up

On Thu, Apr 30, 2009 at 1:38 PM, Benedikt R. <benedikt@rossgardt.de> wrote:
>
> Hey!
>
> I am currently building an app that should be able to parse some
> tables with bank codes. The database table contains about 25,000
> entries.
>
> When I try to request some data ($this->ControllerObj->find
> (conditions)) the server shouts out:
> Fatal error: Allowed memory size of 20971520 bytes exhausted (tried to
> allocate 37 bytes) in /usr/www/users/blzbak/cake/libs/model/
> datasources/dbo/dbo_mysql.php on line 643
>
> Cake doesn't throw an error, when I set ANY LIMIT (either 0 or
> 1000000000000000).
>
> Someone knows, what all this is about?
>
>
> Thank you,
> Benedikt
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Re: Value from Key

I see that You are offended by my last e-mail and for that I offer my humble apologies.

I am not a professional PHP guru and I truly agree with You. Once you make an error you learn from it.
Don't get my opinion wrong, I was also criticized by few cakePHP gurus even tho I do know PHP quite well and I know *how* it *hurts* ;)

Peace,
Faifas

On Thu, Apr 30, 2009 at 19:30, Dave Maharaj :: WidePixels.com <dave@widepixels.com> wrote:
Thanks for the tip...but you can keep your comments to yourself. If i ask a question and make a mistake im glad to those who point it out but you can keep your critiques to yourself. Maybe I am not a professional PHP guru such as yourself but the way you learn is from mistakes.
 
 


From: Aivaras [mailto:faifas1337@gmail.com]
Sent: April-30-09 1:55 PM

To: cake-php@googlegroups.com
Subject: Re: Value from Key

count($results) ?

You surely need to study PHP just a little bit more before diving into a framework :')

Faifas


On Thu, Apr 30, 2009 at 19:06, Dave Maharaj :: WidePixels.com <dave@widepixels.com> wrote:
Thanks to everyone,
 
What i did was:
 
<?php
$i = 0;
  foreach ($results as $error) :
        $i = $i++;
?>
<li><?php  echo $error ;?></li>
<?php endforeach; ?>
 
Its just for tracking a user actions on my site....so if they do something they should not be doing such as messing with the URL  or links/forms  with Firebug it saves the 'bad' info they tried changing it to , where they tied changing it to in a db, and I get a report of who was doing stuff they should not be doing. So thats why the number can change..if they added 5 text fields in a form using Firebug or something i see the 5 fields they added and what they tried to submit.


From: Aivaras [mailto:faifas1337@gmail.com]
Sent: April-30-09 5:06 AM

To: cake-php@googlegroups.com
Subject: Re: Value from Key

for($i = 0; $i < count($array); $i++){
   echo $array[$i]; // will output your error
   echo $i; // will output the index.
}

Still, I have absolutely no idea why would you need to know indexes for error reporting.

Faifas


On Thu, Apr 30, 2009 at 02:30, Dave Maharaj :: WidePixels.com <dave@widepixels.com> wrote:
Right but the [0] [1] will change depending on the array its self.
 
I do not know the number that will be generated as it could be an  array of errors.
 
If there is 1 error [0] but if 10 errors?
 
Ideas?


From: Aivaras [mailto:faifas1337@gmail.com]
Sent: April-29-09 7:42 PM
To: cake-php@googlegroups.com
Subject: Re: Value from Key

Hey,

echo $the_variable_you_are_pr_ing[$key]

example: echo $aNonsenceLetters[0]; // outputs: jkl

Cheers,
Faifas


On Thu, Apr 30, 2009 at 00:47, Dave Maharaj :: WidePixels.com <dave@widepixels.com> wrote:

How can i get the value of a key?

the array is from debug($requests);
for example my array is:

Array
(
   [0] => jkl
   [1] => ii
   [2] => yyy
)
thanks,

Dave











--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Multi Field DisplayField...

Hello all,

This has probably been asked a couple of times allready. I would like
to use multiple fields to generate the labels in a drop down list box.
I searched the list, and this search came up with several different
strategies to achieve this. I tried to implement one of these
strategies but ran in to a problem... I hope someone can help me.

I have the following models:

Member
- id
- login
- last_name
- first_name
-member_type_id

MemberType
- id
- title

Event
- id
- description
- date

Registrations
- id
- event_id
- member_id

I made all the models, controllers and views using the cake bake
console. That gave me allready a lot of funtionality. It's great fun
working with something that does the boring parts for you and allows
you to reach the stage in your project where it becomes more
interesting so fast. This is my first attempt at something with
CakePHP btw, and the main purpose of the application I'm building is
to allow me to learn how to use it. But basically it is an event
registration system for our club.

In the schaffolds that were build the drop down list boxes all jsut
displayed numerical IDs. I understood that this was because I didn't
use "name" or "title" for the database field that has the most
meaningfull description. I solved this by setting $displayField in the
model to something usefull. So in the "Member" model I set
$displayField initalls to "login".

But I would be nice if I could use "first_name last_name" for the
lables in the member_id drop down box on my event registration form. I
found a possible solution here:
http://bakery.cakephp.org/articles/view/multiple-display-field-3
And I decided to use the Set::Combine suggestion made by Barry.

So in the Registrations controller I replaced:

$members = $this->Registration->Member->find('list');

with:

$members = $this->Registration->Member->find('all');
$members = Set::Combine(
$members,
'{n}.Member.ID',
array(
'{0}, {1}',
'{n}.Member.last_name',
'{n}.Member.first_name'
)
);


The weird thing is that with this code the drop down list box that
gets generate for member_id now, in stead of containing a list of al
"login" values, now contained only one value. The last_name +
first_name of the (alphabetically) last member in the table. So the
result of my Set::Combine seems to be an array with just one item.

Now why is that?

Hope someon can help me here.

Krist

--
krist.vanbesien@gmail.com
krist@vanbesien.org
Bremgarten b. Bern, Switzerland
--
A: It reverses the normal flow of conversation.
Q: What's wrong with top-posting?
A: Top-posting.
Q: What's the biggest scourge on plain text email discussions?

--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Memory Limit Exhausted

Hey!

I am currently building an app that should be able to parse some
tables with bank codes. The database table contains about 25,000
entries.

When I try to request some data ($this->ControllerObj->find
(conditions)) the server shouts out:
Fatal error: Allowed memory size of 20971520 bytes exhausted (tried to
allocate 37 bytes) in /usr/www/users/blzbak/cake/libs/model/
datasources/dbo/dbo_mysql.php on line 643

Cake doesn't throw an error, when I set ANY LIMIT (either 0 or
1000000000000000).

Someone knows, what all this is about?


Thank you,
Benedikt

--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Re: Possible very-low-danger bug in view.php (cake core)

There is no check, you are supposed to define $fooPaths variables
correctly. No trailing slash == not correct :)

-Mark

On Apr 29, 10:04 am, Ernesto <e.fanz...@gmail.com> wrote:
> Hello.
>
> here's my bootstrap.php.
>
> if (!defined("SHARED_ITEMS_FOLDER")) {
>         define("SHARED_ITEMS_FOLDER", CAKE_CORE_INCLUDE_PATH . DS ."shared
> items");
>
> }
>
> $modelPaths = array(SHARED_ITEMS_FOLDER ."models");
>
> $viewPaths = array(SHARED_ITEMS_FOLDER ."views");
>
> Please note that i forgot the trailing directory separator.
>
> - Shared models are working.
> - shared views aren't.
>
> maybe there's no trailing DS check in view.php?
--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Eine Frage zu Tabellen Relationen( Error 1054)

Hallo zusammen,

ich habe 2 Tabellen mit folgendem Aufbau

Tabelle 1

masterdata

enthält folgende Felder id, vname, vstrasse, vpostleitzahl, vort,
vgericht, vmitglieder, vgenrenummer, vgenre,vansprechpartner


Tabelle 2

contacts

enthält folgende Felder id canrede, ctitel, cvorname, cname, cstrasse,
cpostleitzahl, cort, ctelefon, cfax

Die Idee ist die das jedem Eintrag der masterdata(Vereinsliste) genau
ein Ansprechpartner zugeordnet ist.
Sozusagen eine hasOne beziehung

mein masterdata Model sieht folgendermaßen aus

class Masterdatum extends AppModel {

var $name = 'Masterdatum';
var $hasOne = array('Contact');

}

mein contact Model sieht so aus

class Contact extends AppModel {

var $name = 'Contact';
}

Welche Änderungen muss ich an meinem Controller Vornehmen, das es auch
so funktioniert. Zur Zeit bekomme ich einen SQL Fehler 1054 und einen
Fehler in der foeach-Schleife der index und view.ctp
Das cakePHP Framework ist das aktuelle 1.2.2.8120.

Kann mir diesbezüglich jemand helfen, denn die Anleitung im cakebook
sind dahingehend irgendwie nicht weit genug. Hat jemand eine gute
Anleitung wie man einfach solche Beziehungen aufbaut und versteht. Das
ist zur Zeit mein größtes Problem. Danke jetzt schon mal

Viele Grüße

Marcus Radisch
--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Re: Auth ignoring Session, redirecting to login under heavy load.

On Thu, Apr 30, 2009 at 5:04 AM, Jonas Hartmann
<j0n4s.h4rtm4nn@googlemail.com> wrote:
>
> Hello,
>
> i have an issue with deploying my cake application. Running local on
> Mac OS X it works like charm. After uploading it to a Ubuntu based
> VHost on HostEurope I had some headaches with PLESK and its strange
> standard unix permission setup.

OT: I'd appreciate it if you posted a quick message discussing some of
the problems you encountered with Plesk and the solutions you found.
I'll soon be deploying something to a Plesk server and, though I've
found a few comments about that online, I haven't seen much in the way
of answers.

> I lose my session from time to time under heavy load. This happens
> with either php, cake or database sessions, I have tried all of them.
> It happens when for Instance I run http://www.domain.tld/admin/categories/index
>  multiple times in Firefox-Tabs at once - thus, if I fire multiple
> http requests very shortly after each other. I have no clue if
> multiple users firing multiple events would lead to the same issue,
> yet (that would be even worse).
>
> I got the latest SVN head from 1.2 stable and just uploaded it to make
> sure that it is not already fixed / an internal problem.
>
> I am looking forward to your help/tips in regards to:
>
> a.) My small controller code, quoted below?
> b.) Debugging tips - how should I continue to understand what the
> problem is?
>
> I have disabled cache and debugging is on 2.
>
> This is how I test against routing prefix admin. I do not know if it
> is the best or recommended way. I would welcome suggestions. Best
> would be if the problem would be fixed afterwards
>
> <?php
>
> class AppController extends Controller {
>
>        var $helpers = array('Html', 'Form', 'Javascript', 'Time');
>        var $components = array('Cookie', 'Session', 'Auth');
>
>        function beforeFilter() {
>                if(isset($this->params['prefix'])) {
>                        if($this->params['prefix'] == 'admin') {
>                                Configure::write('debug', 2);
>                                $this->Auth->deny('*');
>                                $this->Auth->allow('login');
>                        } else {
>                                $this->Auth->allow('*');
>                        }
>                } else {
>                        $this->Auth->allow('*');
>                }
>        }
>
> }
> ?>

You should never include 'login' in allow().

This is how I have things working:

AppController:
function beforeFilter()
{
$this->Auth->fields = array('username' => 'email', 'password' => 'password');
$this->Auth->loginError = 'No matching user found.';
$this->Auth->loginAction = array('controller' => 'users', 'action' => 'login');
$this->Auth->loginRedirect = array('controller' => 'pages', 'action'
=> 'display', 'home');
$this->Auth->autoRedirect = false;
$this->Auth->logoutRedirect = array('controller' => 'users', 'action'
=> 'login');

/* Auth will check controller's isAuthorized()
*/
$this->Auth->authorize = 'controller';

/* I have no public pages, so I need a better authError
* than the default 'You are not authorized to access that
* location.' for users who haven't loged in yet.
*/
if (!$this->Session->read('User'))
{
$this->Auth->authError = 'Please log in';
}

$admin = Configure::read('Routing.admin');
if (isset($this->params[$admin]) && $this->params[$admin])
{
$this->layout = 'admin';
}
}

function isAuthorized()
{
$admin = Configure::read('Routing.admin');
if (isset($this->params[$admin]) && @isset($this->params['prefix'][$admin]))
{
/* see User::login()
*/
if ($this->Auth->user('admin') == 0)
{
return false;
}
}
return true;
}

UsersController:

public function login()
{
if ($user = $this->Auth->user())
{
/* All my Groups below 4 are some kind of admin
*/
if ($this->Auth->user('group_id') > 3)
{
$this->redirect($this->Auth->loginRedirect);
}

/* This User is an admin. You might already have an
* 'admin' field in your table. I chose not to so I set it
* in Auth's session values.
*/
$this->Session->write('Auth.User.admin', 1);

/* The redirect for an admin can be whatever you need
*/
$this->redirect(
array(
'controller' => 'admin',
'action' => 'index',
'admin' => 1
)
);
}
}

--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

routing to a non-cake php page (again)

Hi Bakers,

I want to use routes to point /about to /blog/about, i.e in webroot,
not a controller/action combo.

I know I could do this mod rewrite, and it'd be better for performance
etc, but given some tight deadlines and a lot of legacy routes to
change, it'd be lots simpler for me to do something like:

Router::connect('/about', array('url' => '/blog/about'));

Is this possible? Or does routing still not apply to things in
webroot?


(There's a thread with the above title that's basically what I'm
asking about, but that was a long time ag, and I thought things might
have changed since then?!)
--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

who can help me about ACL?

Hi,everyone!

I have a problem about ACL, there always a warnning like
this:
" DbAcl::allow() - Invalid node [CORE\cake\libs\controller
\components\acl.php, line 325"

who know this,please help me! 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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

RE: Value from Key

Thanks for the tip...but you can keep your comments to yourself. If i ask a question and make a mistake im glad to those who point it out but you can keep your critiques to yourself. Maybe I am not a professional PHP guru such as yourself but the way you learn is from mistakes.
 
 


From: Aivaras [mailto:faifas1337@gmail.com]
Sent: April-30-09 1:55 PM
To: cake-php@googlegroups.com
Subject: Re: Value from Key

count($results) ?

You surely need to study PHP just a little bit more before diving into a framework :')

Faifas


On Thu, Apr 30, 2009 at 19:06, Dave Maharaj :: WidePixels.com <dave@widepixels.com> wrote:
Thanks to everyone,
 
What i did was:
 
<?php
$i = 0;
  foreach ($results as $error) :
        $i = $i++;
?>
<li><?php  echo $error ;?></li>
<?php endforeach; ?>
 
Its just for tracking a user actions on my site....so if they do something they should not be doing such as messing with the URL  or links/forms  with Firebug it saves the 'bad' info they tried changing it to , where they tied changing it to in a db, and I get a report of who was doing stuff they should not be doing. So thats why the number can change..if they added 5 text fields in a form using Firebug or something i see the 5 fields they added and what they tried to submit.


From: Aivaras [mailto:faifas1337@gmail.com]
Sent: April-30-09 5:06 AM

To: cake-php@googlegroups.com
Subject: Re: Value from Key

for($i = 0; $i < count($array); $i++){
   echo $array[$i]; // will output your error
   echo $i; // will output the index.
}

Still, I have absolutely no idea why would you need to know indexes for error reporting.

Faifas


On Thu, Apr 30, 2009 at 02:30, Dave Maharaj :: WidePixels.com <dave@widepixels.com> wrote:
Right but the [0] [1] will change depending on the array its self.
 
I do not know the number that will be generated as it could be an  array of errors.
 
If there is 1 error [0] but if 10 errors?
 
Ideas?


From: Aivaras [mailto:faifas1337@gmail.com]
Sent: April-29-09 7:42 PM
To: cake-php@googlegroups.com
Subject: Re: Value from Key

Hey,

echo $the_variable_you_are_pr_ing[$key]

example: echo $aNonsenceLetters[0]; // outputs: jkl

Cheers,
Faifas


On Thu, Apr 30, 2009 at 00:47, Dave Maharaj :: WidePixels.com <dave@widepixels.com> wrote:

How can i get the value of a key?

the array is from debug($requests);
for example my array is:

Array
(
   [0] => jkl
   [1] => ii
   [2] => yyy
)
thanks,

Dave








--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Re: Value from Key

count($results) ?

You surely need to study PHP just a little bit more before diving into a framework :')

Faifas


On Thu, Apr 30, 2009 at 19:06, Dave Maharaj :: WidePixels.com <dave@widepixels.com> wrote:
Thanks to everyone,
 
What i did was:
 
<?php
$i = 0;
  foreach ($results as $error) :
        $i = $i++;
?>
<li><?php  echo $error ;?></li>
<?php endforeach; ?>
 
Its just for tracking a user actions on my site....so if they do something they should not be doing such as messing with the URL  or links/forms  with Firebug it saves the 'bad' info they tried changing it to , where they tied changing it to in a db, and I get a report of who was doing stuff they should not be doing. So thats why the number can change..if they added 5 text fields in a form using Firebug or something i see the 5 fields they added and what they tried to submit.


From: Aivaras [mailto:faifas1337@gmail.com]
Sent: April-30-09 5:06 AM

To: cake-php@googlegroups.com
Subject: Re: Value from Key

for($i = 0; $i < count($array); $i++){
   echo $array[$i]; // will output your error
   echo $i; // will output the index.
}

Still, I have absolutely no idea why would you need to know indexes for error reporting.

Faifas


On Thu, Apr 30, 2009 at 02:30, Dave Maharaj :: WidePixels.com <dave@widepixels.com> wrote:
Right but the [0] [1] will change depending on the array its self.
 
I do not know the number that will be generated as it could be an  array of errors.
 
If there is 1 error [0] but if 10 errors?
 
Ideas?


From: Aivaras [mailto:faifas1337@gmail.com]
Sent: April-29-09 7:42 PM
To: cake-php@googlegroups.com
Subject: Re: Value from Key

Hey,

echo $the_variable_you_are_pr_ing[$key]

example: echo $aNonsenceLetters[0]; // outputs: jkl

Cheers,
Faifas


On Thu, Apr 30, 2009 at 00:47, Dave Maharaj :: WidePixels.com <dave@widepixels.com> wrote:

How can i get the value of a key?

the array is from debug($requests);
for example my array is:

Array
(
   [0] => jkl
   [1] => ii
   [2] => yyy
)
thanks,

Dave









--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

RE: Value from Key

Thanks to everyone,
 
What i did was:
 
<?php
$i = 0;
  foreach ($results as $error) :
        $i = $i++;
?>
<li><?php  echo $error ;?></li>
<?php endforeach; ?>
 
Its just for tracking a user actions on my site....so if they do something they should not be doing such as messing with the URL  or links/forms  with Firebug it saves the 'bad' info they tried changing it to , where they tied changing it to in a db, and I get a report of who was doing stuff they should not be doing. So thats why the number can change..if they added 5 text fields in a form using Firebug or something i see the 5 fields they added and what they tried to submit.


From: Aivaras [mailto:faifas1337@gmail.com]
Sent: April-30-09 5:06 AM
To: cake-php@googlegroups.com
Subject: Re: Value from Key

for($i = 0; $i < count($array); $i++){
   echo $array[$i]; // will output your error
   echo $i; // will output the index.
}

Still, I have absolutely no idea why would you need to know indexes for error reporting.

Faifas


On Thu, Apr 30, 2009 at 02:30, Dave Maharaj :: WidePixels.com <dave@widepixels.com> wrote:
Right but the [0] [1] will change depending on the array its self.
 
I do not know the number that will be generated as it could be an  array of errors.
 
If there is 1 error [0] but if 10 errors?
 
Ideas?


From: Aivaras [mailto:faifas1337@gmail.com]
Sent: April-29-09 7:42 PM
To: cake-php@googlegroups.com
Subject: Re: Value from Key

Hey,

echo $the_variable_you_are_pr_ing[$key]

example: echo $aNonsenceLetters[0]; // outputs: jkl

Cheers,
Faifas


On Thu, Apr 30, 2009 at 00:47, Dave Maharaj :: WidePixels.com <dave@widepixels.com> wrote:

How can i get the value of a key?

the array is from debug($requests);
for example my array is:

Array
(
   [0] => jkl
   [1] => ii
   [2] => yyy
)
thanks,

Dave






--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

RE: Compare Array - GOT IT!

Yes... the goal is to secure the form (the checkbox values) so an end user
can not modify the values and submit...All values submitted are checked
against possible values in the db...so if they don't exist we know someone
was messing with the form. So that's all done and working.... then it was
just a matter of selecting the fields that were allowed to have data saved
to them so if a user tried to add text field or something to the form it
would not save that 'extra' data.

The validation is set ('numeric') since its a HABTM table its saving id,
user id , program_id

That was all...sorry for the confusion

Dave

-----Original Message-----
From: Brendon Kozlowski [mailto:BrendonKoz@hotmail.com]
Sent: April-30-09 11:48 AM
To: CakePHP
Subject: Re: Compare Array - GOT IT!


Ah, okay I understand what you mean now. It looks like you're doing this in
the model; am I correct on that? It should probably be set as a custom
validation for the particular field(s) you are concerned about. Since you
didn't paste all of your code (you don't need to) I'll just hope that's what
you're doing. :) If not, you can find that information in the cookbook:
http://book.cakephp.org/view/150/Custom-Validation-Rules

If you're not already, you may also want to use the Security Component.

On Apr 29, 10:11 pm, "Dave Maharaj :: WidePixels.com"
<d...@widepixels.com> wrote:
> No no...not giving them the ability to edit the form...install Firebug
> and anyone can edit a form...I am trying to prevent them from editing the
form.
>
> I can see the form and use firebug to see the vales in the form
> checkboxes...value = 1 =3 = so on..... I can change the values with
> Firebug to 599 799 899 or what ever ...so what I am doing is verify
> that if someone is being cleaver and changes the values to something
> that it could not possably be then it will not save anything and the
> logged in users account is supspended because the ony way the form
> would not save is if someone was messing with it and submited bad
> data.(the form is only checkboxes)
>
>
>
> -----Original Message-----
> From: Brendon Kozlowski [mailto:Brendon...@hotmail.com]
> Sent: April-29-09 11:15 PM
> To: CakePHP
> Subject: Re: Compare Array - GOT IT!
>
> I don't believe this is necessary in the first place.  Why are you
> giving someone the ability to edit the form that shouldn't be?  That's
> the first issue I see.  Secondly, why are you passing values to be
> saved if you don't want them overwritten?  That's the 2nd issue.
> Thirdly, why are you even rendering them as form elements rather than
> simple text within a paragraph tag instead?  That'd be the third issue I
see.
>
> Although you are accomplishing what you want to do, I don't believe
> you should be trying to do it in the first place as a more elegant
> (albeit possibly more difficult to grasp?) solution is available.
>
> On Apr 29, 4:52 pm, "Dave Maharaj :: WidePixels.com"
> <d...@widepixels.com> wrote:
> > I figured it out.
>
> > //list of possible keys
> >                                  $keys =
> > $this->User->$model_name->find('list', array('fields' => 'id', 'order'
> > => 'id ASC'));
> >                                  debug($keys);
>
> >                                 $submitted =
> > $this->data[$model_name][$model_name];
>
> > debug($this->data[$model_name][$model_name]);
>
> >                                 $results = array_diff($submitted,
> > $keys);
> >                                 debug($results);
>
> > So if a "evil" user tries to change the value in a form and submits,
> > the value is checked against possible values in the databsae....if
> > not found we know someone was doing something they should not have been
doing.
>
> > I am using this for a form that only has checkboxes so it works for me.
>
> > Any flaws?
>
> > Thanks,
>
> > Dave
>
> > -----Original Message-----
> > From: Dave Maharaj :: WidePixels.com [mailto:d...@widepixels.com]
> > Sent: April-29-09 6:14 PM
> > To: cake-php@googlegroups.com
> > Subject: re: Compare Array
>
> > I am trying to do the same type thing with comparing an array. I am
> > using this for a security set up so a user can not change values of
> > a form so I get the list of possible keys
>
> > //list of possible keys
> >      $keys = $this->User->$model_name->find('list', array('fields'
> > => 'id', 'order' => 'id ASC'));
> >      debug($keys);
>
> > Array
> > (
> >     [1] => 1
> >     [2] => 2
> >     [3] => 3
> >     [4] => 4
> >     [5] => 5
> >     [6] => 6
> > )
>
> >     // values submitted by user
> >     $submitted =  $this->data[$model_name][$model_name];
> >     debug($this->data[$model_name][$model_name]);
>
> > Array
> > (
> >     [0] => 3
> >     [1] => 5
> >     [2] => 6
> >     [3] => 1
> > )
>
> >         //how to compare vales against submitted values?
> >     $results = array_udiff_assoc($keys, array($submitted));
> >     debug($results);
>
> > But i need to compare the keys with the submitted data and that
> > where i am stuck. I need to check that the submitted values have a
> > match with the possible values in the database.
>
> > Can someone point out my error or suggestions?
>
> > Thanks,
>
> > Dave- Hide quoted text -
>
> - Show quoted text -


--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Syntax-Error

Can somebody ecplain me what I am doing wrong?

http://pastebin.com/m79236652

--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Is this even possible in cake? (model associations with unknown models)

My site is build with a lot of plugins.
Now, I used to use a 'pages' table that had the column called
'widgets'
the column contained a serialized array which contained information
about which widgets (models) should be in that page. Something like
this:

array(
[0] => array(
'name' => 'content'
'args' => array(
'id' => 1
)
)
[1] => array(
'name' => 'comments'
'args' => array(
'group_id' => 1
)
)
)

Then I had plugin-models called 'Content' and 'Comments' which had
tables like 'content_data', 'content_settings', 'comments_data' and
'comments_settings'.

Now someone told me I should never ever have an array inside a
database-table.
So I tried to do it without an array, and got up with this database
structure:

A table called 'pages'
A table called 'widgets' with columns called 'id' and 'page_id'
And all my widgets ('content_data' and 'comments_data') got an extra
column called 'widget_id'

Now I wanted to give my widgets a
var $belongsTo = array('widgets');

But I can't give my 'widgets'-model a
var $hasMany = array(?);
Cause I don't know which widgets are on a page.
Of course, I could try to associate it with EVERY widget (although I
wouldn't know how), but that would be very slow when I get a lot of
widgets.

So, how do I give it the right $hasMany-var?
--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---