Sunday, November 30, 2008

AW: how to translate the pagination words: "next" and "previous"

Hi Ahmed,

If you have these expressions only at one view that is the easiest solution. However: if you have a big application working with localization is cleaner.
It has the advantage, that you have all your GUI strings in one place and when you want to change one of them later you know where to look.

Greetings Anja

-----Ursprüngliche Nachricht-----
Von: cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] Im Auftrag von ahmedhelmy007
Gesendet: Sonntag, 30. November 2008 21:34
An: CakePHP
Betreff: Re: how to translate the pagination words: "next" and "previous"


i found another easy way to translate the two words: "next" and "previous" , simply by passing the arabic word to the function as an
argument:

$paginator->prev("السابق");
$paginator->next("التالي");


On Nov 29, 6:05 pm, "Federico Rinaldi" <federicorina...@gmail.com>
wrote:
> You should use Localization:
>
> http://book.cakephp.org/view/162/Localizing-Your-Application
>
> And internationalization
>
> http://book.cakephp.org/view/163/Internationalization-in-CakePHP
>
> Regards,
>
> FedeX
>
> On Sat, Nov 29, 2008 at 10:07 AM, ahmed sabrah <ahmedhelmy...@gmail.com>wrote:
>
>
>
>
>
> > i'm new to cakePHP, and i need the pagination words : "next" and
> > "previous" to be translated into arabic.
> > should i search for an arabic language translation for the cakePHP ?
> > and if that is the case, can any one tell me where to download it ?
>
> > sorry for my bad english.- 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: validation in model

thanks, yes i just discovered that myself and now I realise that the
validation has to be different for create and update.

create: needs to check that the name is unique,
update: is unique except for the edited record.

Is the best way to accomplish this by creating another function for
validation on 'update'?

or change the current validation to validate depending on what the action
is?

thanks


David C. Zentgraf wrote:
>
>
> What you're looking for is this:
> http://book.cakephp.org/view/131/on
>
> On 1 Dec 2008, at 16:06, AngeloZanetti wrote:
>
>>
>>
>> Hi all,
>>
>> Is it possible to have model validation only be called when there is
>> an add
>> action and not edit for example ?
>>
>> I have added unique name validation but now with the edit of a
>> record it
>> still gives a validation error as that name of that record already
>> exists.
>>
>> My code as follows:
>>
>> var $validate = array(
>> 'question' => array(
>> 'Question already exists, please enter a
>> unique
>> question' => array(
>> 'rule' => array(
>>
>> 'isUnique',
>> 'question'
>> )
>> ),
>> 'This field cannot be left blank' =>
>> VALID_NOT_EMPTY
>> ),
>>
>> function isUnique($field, $value) {
>>
>> $fields[$this->name.'.'.$value] = $field[$value];
>> $this->recursive = -1;
>>
>> if ($this->hasAny($fields)) {
>> $this->invalidate('unique_'.$field);
>> return false;
>> } else {
>>
>> return true;
>> }
>> }
>>
>> thanks in advance.
>>
>> --
>> View this message in context:
>> http://www.nabble.com/validation-in-model-tp20767005p20767005.html
>> Sent from the CakePHP mailing list archive at Nabble.com.
>>
>>
>> >
>
>
> >
>
>

--
View this message in context: http://www.nabble.com/validation-in-model-tp20767005p20767279.html
Sent from the CakePHP mailing list archive at Nabble.com.


--~--~---------~--~----~------------~-------~--~----~
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: Check Unique in a model

I have got a similiar problem that the validation works for adding must it
mustn't validate when editing the record as its going to have the same name
in DB as the form when editing.

how can we disable this for the edit function? or must it be done in the
controller?

jonknee wrote:
>
>
>> In fact, it seems that this built-in rule doesn't work!
>> Why is this not yet fixed? We allways need to check unicity of a field
>> in all of our applications...
>
> What's not working for you? It seems to be working for me. I had a
> custom method until I was told about isUnique working through
> validation and after updating my code it seemed to keep working.
>
>

--
View this message in context: http://www.nabble.com/Check-Unique-in-a-model-tp16473557p20767209.html
Sent from the CakePHP mailing list archive at Nabble.com.


--~--~---------~--~----~------------~-------~--~----~
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: validation in model

What you're looking for is this:
http://book.cakephp.org/view/131/on

On 1 Dec 2008, at 16:06, AngeloZanetti wrote:

>
>
> Hi all,
>
> Is it possible to have model validation only be called when there is
> an add
> action and not edit for example ?
>
> I have added unique name validation but now with the edit of a
> record it
> still gives a validation error as that name of that record already
> exists.
>
> My code as follows:
>
> var $validate = array(
> 'question' => array(
> 'Question already exists, please enter a
> unique
> question' => array(
> 'rule' => array(
>
> 'isUnique',
> 'question'
> )
> ),
> 'This field cannot be left blank' =>
> VALID_NOT_EMPTY
> ),
>
> function isUnique($field, $value) {
>
> $fields[$this->name.'.'.$value] = $field[$value];
> $this->recursive = -1;
>
> if ($this->hasAny($fields)) {
> $this->invalidate('unique_'.$field);
> return false;
> } else {
>
> return true;
> }
> }
>
> thanks in advance.
>
> --
> View this message in context: http://www.nabble.com/validation-in-model-tp20767005p20767005.html
> Sent from the CakePHP mailing list archive at Nabble.com.
>
>
> >


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

validation in model

Hi all,

Is it possible to have model validation only be called when there is an add
action and not edit for example ?

I have added unique name validation but now with the edit of a record it
still gives a validation error as that name of that record already exists.

My code as follows:

var $validate = array(
'question' => array(
'Question already exists, please enter a unique
question' => array(
'rule' => array(
'isUnique',
'question'
)
),
'This field cannot be left blank' =>
VALID_NOT_EMPTY
),

function isUnique($field, $value) {

$fields[$this->name.'.'.$value] = $field[$value];
$this->recursive = -1;

if ($this->hasAny($fields)) {
$this->invalidate('unique_'.$field);
return false;
} else {

return true;
}
}

thanks in advance.

--
View this message in context: http://www.nabble.com/validation-in-model-tp20767005p20767005.html
Sent from the CakePHP mailing list archive at Nabble.com.


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

Invite Application... need some design help..!

Hey all -- new here, new to CakePHP, but loving it so far. I need some
design suggestions.

I'm writing an application that involves inviting people to a page.

The invites will go out to registered users of the application
("Friends" of the Invitation Owner) and to non-registered users via
email address submission.

How can I organize invitees associated with any given invitation in my
MySQL database since some will be registered ("Users" model), and some
un-registered (list of email addresses)...? Should I use separate
tables or models for registered invitees and un-registered invitees?

Right now, I've got a working Users model and have a self-referenced
HABTM association for "Friend" lists, that uses a little join table to
link Users with their Friends' user_id's.

In other words, I'm having trouble designing how my Invite model and
database should look like so that registered Users and un-registered
Users (that the app will only have email addresses for) are linked
together for any given Invite.

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: Copied cake PHP files to a new Ubuntu Intrepid box and nothing is working

Thanks for the suggestions, you were right, I went through the phpinfo
() for the old and new servers and was actually missing one of the
core components.
Completely overlooked it without even thinking about it. Was missing
the mysql module for PHP5... yah slightly important. :-p

All is working now, thanks for the pointers!


On Nov 30, 5:17 pm, "Howard Glynn" <hgl...@gmail.com> wrote:
> Are you sure you have sufficient php modules installed with ubuntu package
> manager?
>
> I would compare your phpinfo() on the original box versus the new box(), or
> even just have a look at what is ticked related to php on synaptic package
> manager. If I saw that error message I'd be looking at libraries straight
> away.
>
> You may not get everything you think you ought to by default.
>
> On Sun, Nov 30, 2008 at 5:52 AM, Nick <nlof...@gmail.com> wrote:
>
> > I'm desperate for some help here...  I just built a brand new ubuntu
> > intrepid server and copied everything from my cake folders on my
> > Ubuntu Hardy box to the new intrepid server.
>
> > If I extract a fresh version of Cake, everything works fine, css shows
> > up, db calls work correctly, etc., but everything is failing when I
> > copy all my work over.
>
> > I see no CSS formatting and I get the following error:
>
> > Fatal error: Call to undefined function mysql_connect() in /home/phazo/
> > Dropbox/www/lymtest3/cake/libs/model/datasources/dbo/dbo_mysql.php on
> > line 117
>
> > I've dumped my sql database and imported it on the new device
> > triple checked the sql accounts
> > made sure my tmp directory is writeable
> > enabled MOD rewrites
> > verified my .htaccess files exist
> > set "AllowOverride all" for my directories in the apache2.conf file
>
> > what else could I be missing?
> > Thanks for any help anyone can provide!
--~--~---------~--~----~------------~-------~--~----~
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: How to use Prefix Routing for form submit

Thanks Kyo,

Your solution is working fine but sometimes I am not using URL as form
action in this case I am finding problem...

like if url is
http://localhost/test/education/blogs/add/

and I want to handale form post action on education_index then your
suggested solution is not working....

Please tell me how should I do this?

Thanks


On Nov 28, 6:54 pm, Kyo <ready2jam2ni...@yahoo.co.jp> wrote:
> Try something like:
>
>         echo $form->create(null, array('url'=>"/{$this->params['url']
> ['url']}"));
>
> $params['url']['url'] holds the url of the current page.
> That should do the trick.
>
> hth
--~--~---------~--~----~------------~-------~--~----~
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: total newbie - Config question

On defining ROOT I forgot to say change CakePHP to whatever folder you
have called your cake folder.

On Nov 30, 7:08 pm, "Scott Powell" <scottpowe...@gmail.com> wrote:
> Thanks for the help. Will do this.
>
> -----Original Message-----
> From: cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] On Behalf
>
> Of thatsgreat2345
> Sent: Sunday, November 30, 2008 11:42 PM
> To: CakePHP
> Subject: Re: total newbie - Config question
>
> DO NOT PUT CAKEPHP IN PUBLIC_HTML! I have hostgator as well, this is
> what you do put it above public_html so it will not be accessible by
> anyone. Then take webroot folder out of the app folder which is inside
> the cake folder, and upload it to your public html, or if the cakeapp
> is going to be your site just upload the contents of webroot folder to
> public_html. Then edit index.php in your webroot folder that you have
> just added to public_html and change these 2 lines
>
> if (!defined('ROOT')) {
>                 define('ROOT', DS.'home'.DS.'YOUR HOSTGATOR
> USERNAME'.DS.'CakePHP');
>         }
>
> and if you have changed the app folder name from app to something else
> then change this line too
> if (!defined('APP_DIR')) {
>                 define('APP_DIR', 'APP FOLDER NAME');
>         }
>
> On Nov 30, 10:01 am, rgreenphotodesign <rgr...@rgreenphotography.com>
> wrote:
> > Do you have your domain home directory/doc root pointed to /possible
> > sub dir/app/webroot/?
>
> > On Nov 29, 7:49 pm, scott <scottpowe...@gmail.com> wrote:
>
> > > Hello all,
>
> > > Just started learning CakePHP and am excited at the possibilities, but
> > > have hit my first snag.
>
> > > This is my first post and have read the documentation, but cannot find
> > > the solution to my problem.
>
> > > I uploaded the full cake package to my server into the root directory
> > > which is public_html. I'm using Hostgator which has php 5 and
> > > mod_rewrite activated.
>
> > > I can only get the home page to show up when I set ReWriteEngine  to
> > > "off". If it is on, I get 404 not found.
>
> > > Also, I don't know if this is a problem, but I don't have an active
> > > domain pointed to it. So I access the root directory
> bywww.mainserverexample.com/~cake
>
> > > Thanks in advance for your help,
>
> > > Scott
>
> No virus found in this incoming message.
> Checked by AVG.
> Version: 7.5.549 / Virus Database: 270.9.10/1810 - Release Date: 11/24/2008
> 2:36 PM
>
> No virus found in this outgoing message.
> Checked by AVG.
> Version: 7.5.549 / Virus Database: 270.9.10/1810 - Release Date: 11/24/2008
> 2:36 PM
--~--~---------~--~----~------------~-------~--~----~
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: total newbie - Config question

Thanks for the help. Will do this.

-----Original Message-----
From: cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] On Behalf
Of thatsgreat2345
Sent: Sunday, November 30, 2008 11:42 PM
To: CakePHP
Subject: Re: total newbie - Config question


DO NOT PUT CAKEPHP IN PUBLIC_HTML! I have hostgator as well, this is
what you do put it above public_html so it will not be accessible by
anyone. Then take webroot folder out of the app folder which is inside
the cake folder, and upload it to your public html, or if the cakeapp
is going to be your site just upload the contents of webroot folder to
public_html. Then edit index.php in your webroot folder that you have
just added to public_html and change these 2 lines

if (!defined('ROOT')) {
define('ROOT', DS.'home'.DS.'YOUR HOSTGATOR
USERNAME'.DS.'CakePHP');
}

and if you have changed the app folder name from app to something else
then change this line too
if (!defined('APP_DIR')) {
define('APP_DIR', 'APP FOLDER NAME');
}

On Nov 30, 10:01 am, rgreenphotodesign <rgr...@rgreenphotography.com>
wrote:
> Do you have your domain home directory/doc root pointed to /possible
> sub dir/app/webroot/?
>
> On Nov 29, 7:49 pm, scott <scottpowe...@gmail.com> wrote:
>
> > Hello all,
>
> > Just started learning CakePHP and am excited at the possibilities, but
> > have hit my first snag.
>
> > This is my first post and have read the documentation, but cannot find
> > the solution to my problem.
>
> > I uploaded the full cake package to my server into the root directory
> > which is public_html. I'm using Hostgator which has php 5 and
> > mod_rewrite activated.
>
> > I can only get the home page to show up when I set ReWriteEngine  to
> > "off". If it is on, I get 404 not found.
>
> > Also, I don't know if this is a problem, but I don't have an active
> > domain pointed to it. So I access the root directory
bywww.mainserverexample.com/~cake
>
> > Thanks in advance for your help,
>
> > Scott

No virus found in this incoming message.
Checked by AVG.
Version: 7.5.549 / Virus Database: 270.9.10/1810 - Release Date: 11/24/2008
2:36 PM

No virus found in this outgoing message.
Checked by AVG.
Version: 7.5.549 / Virus Database: 270.9.10/1810 - Release Date: 11/24/2008
2:36 PM


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

Pagination Ordering

Okay, google isn't helping me find the answer to this one, hopefully
someone else can point me to what is probably an obvious answer...

How can one setup multiple levels or ordering for pagination?

For example: My user listing has a default pagination order of
'User.last_name', but when I select another column (say 'state') the
results are sorted by state only (results from the same state are
listed in the order they are in the database).

Can I setup pagination to sort results by state,last_name (i.e. use a
secondary ordering), or do I need to setup a custom query for this?

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

Need help planning my application (associations question)

Hi all,

New here, new to CakePHP, but loving it so far.

I'm working on planning a basic invitation application, but I'm
struggling with how to plan my database and some model associations.

A few things about my current setup:

- CakePHP 1.2-latest, Apache, MySQL
- I have a working User (authentication) model

For this invitation system, there are a few seemingly simple
requirements that I'm struggling to design properly within Cake:

- Users can invite Friends to events.
- Users can invite Users to events.
- Friends are registered users that Users have added to their Friends
list.

In other words, all persons invited to an event are registered users.
However, some are marked Friends and some aren't. How can I relate
this all properly to the User model? I think I have a few of these
right, but I'm wondering if there's a better way to keep Friends Lists
and also associate both Friends and non-Friends (Users) to
Invitations.

- Invitations "belongTo" a User (the creator/owner).
- User "hasMany" Invitations.
- Invitations have many invitees which can be Friends or non-Friends
-- all of which are Users.

How do I store my list of all the invitees for an Invitation? Would I
need an Aquaintances model (for non-Friends that are invited) with an
hasAndBelongsToMany association and use a join table in MySQL? Or
would there be a simpler design...

Currently, I've got a working Friends List by using a join table that
stores user_id and friend_id.

All feedback is greatly appreciated, be gentle, I'm new to PHP and
specifically CakePHP. :)

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

Mail Queuing in CakePHP

Hi,

In my rewrite of a system into CakePHP, I need to implement a Mail
Queue (storing mail messages in a database for later sending in order
not to overwhelm the SMTP server). My previous application used the
PEAR Mail::Queue class for this, and it always worked perfectly.

I've searched for similar Cake options, but haven't really found
anything comparable. My options therefore seem to be:

1. Integrate the PEAR class into my application.

- Searching for people who have attempted this gives
http://bakery.cakephp.org/articles/view/integrating-pear-pager as the
top result. The wrapper code seems rather extensive.

2. Integrate a Zend Framework class

- I've never used Zend Framework before, but it looks very interesting
and seems to have less overhead than PEAR. This tutorial:

http://bakery.cakephp.org/articles/view/integrating-zend-framework-lucene-with-your-cake-application

seems to be a pretty tight example of how to integrate the two
frameworks/elements.

3. Write my own

- I'm not particularly keen to do this unless I have to, partly due to
laziness and partly due to the feeling that this sort of thing should
be standardised as with PEAR. There is some previous discussion on
doing this here:

http://groups.google.com/group/cake-php/browse_thread/thread/44fac5e4c87ad053.


I would really appreciate any comments on this, either specifically as
to the best way to do Mail Queing or in general as to implementing
other frameworks into CakePHP.

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

Error: Database table tr_instuctors for model Instructors was not found.

So just started using CakePHP, and i'm getting this error:

Error: Database table tr_instuctors for model Instructors was not
found.

As you may notice, tr_instuctors is spelled wrong, it is missing the
first 'r'. All my model names and controller names as spelled
correctly. Any ideas??

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: Using model without a database for form

On Oct 2, 10:49 am, sniper <suren...@gmail.com> wrote:
> i finally got it! i searched "cakephp _schema" and got this linkhttp://snook.ca/archives/cakephp/contact_form_cakephp/
> when i implemented it, to my surprise it worked! So i striped my cheer
> model to exactly like contact one and that too worked.
> So turns out (after little debugging) i had to call parent class
> constructor since i was doing some init in my constructor.
> i added a line parent::__construct(); this fixed the problem
>

hi sniper

i've created a tableless model and have same trouble with you,
where should i put thec parent::_construct() in my constructor?

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: MVC falling to pieces for modern AJAX apps

wirtsi,

I honestly think you're takoing the wrong approach here.
For example: emdedding alert() calls in your models??? How fragile a
system will that create? How will you use your business logic in CRON
jobs/ other contexts? I know progressive enhancement has its own
issues, but I think it's much better than the system you seem to have
in mind.

For example, I often use JQuery to do stuff like this:

- standard cake form on the page
- hijack it with JQ to do an ajax submit
- parse the results in JQ (real easy) and insert field/validation
messages into the page dynamically

You can take this further and (as per James K's very good response)
ask for different outputs depending upon the extension -
i.e add .json to the form action URLs so they return data easily used
by JS.

Advantages of this approach are numerous: your site can still work
without JS, is more secure, is reliable cross-platform, with less
coupling, you can keep your JS code in .js files (where it belongs)
and there are SEO benefits!

I know that there are issues with the way important business logic is
spread throughout the server and client layers, but I don't think this
is a MVC issue specifically - it's just the cost of pushing the
boundaries of web apps. And as James mentioned, you'll always need a
foundation of server side code for security etc, and trust me, always
having a working mechanism for your users (even as a backup) in case
your javascript doesn't work in their environment is a big advantage.

Imho, you should try and push the progressive enhancement / separation
of concerns as far as you can before you consider opting for
integrating the client side code with your business logic...

Sorry for the long response, but it appears I have quite strong
feelings on the subject :)


On Nov 30, 4:47 pm, wirtsi <florian.kra...@googlemail.com> wrote:
> James, that ExtHelper of yours would truly be very interesting to
> me ... I've been wrapping my head around Ext the last few weeks and I
> really like the possibilities it gives you creating spot on user
> interfaces .. I just found it a massive pain to get the data over from
> Cake, especially with 1:n or n:m relationships which I more or less
> had to put back together by hand in ext (because I had to flatten the
> data output list to one level) but then perhaps I haven't quite
> grasped all that DataReader stuff yet.
>
> I really like the idea just using a form submit to validate the
> data ... I was thinking along the lines of per field ajax submit &
> validate (like you see in the ext demos .. field is empty, ext
> complains about it right away) but what the heck, this seems so much
> easier :). Do you validate only after a user submits (via ajax) or do
> you submit periodically to display errors on the fly? In latter case I
> could image one could get quite a few duplicate entries if the user
> happens to fill out all the fields correctly.
>
> But to get back to my original post, how would it sound if Cake
> allowed for user defined JavaScript functions in the model definition.
> For example "name" NOT_EMPTY but also "alert('Must not be empty') so
> the server checks the field on submit (in case anyone was fiddling
> around with the post data) but the javascript function gets pushed
> through to the view.
>
> Ok, that would be having view code in the model but on the other hand
> this code is definitely related to the models data.
>
> Thanks for your input
>
> wirtsi
>
> On 30 Nov., 16:07, James K <james.m.k...@gmail.com> wrote:
>
> > Strongly disagree.
>
> > I'm in the middle of a massive CakePHP/ExtJS development and it works
> > like a dream (To date: 40 controllers, 89 models). A lot of our
> > controller actions simply return JSON. Cake is perfectly suited to
> > this. Grab your data, do some set::extract manipulation on it if
> > necessary, and use the object method of the javascript helper to send
> > it to the client as JSON.
>
> > Also you should ALWAYS validate your data on the server side. Client
> > side validation is not reliable or secure. You can add it in as a
> > slight convenience to the user, but your application should never ever
> > rely on client side validation to do its job.
>
> > The technique we're currently using is we load Cake's forms into ExtJS
> > panels that proceed to digest the DOM elements (configure the form in
> > Ext, set the contentEl properties of the different panels to the ids
> > of the divs or fieldsets generated by cake) and then submit them via
> > AJAX back to the server. When the panel comes back, it has Cake's
> > validation messages next to the appropriate fields. This technique
> > also allows us to leverage the added security of the Security
> > component to ensure that no one's using Firebug or something similar
> > to allow them to submit data they aren't supposed to (which is a major
> > security risk a lot of developers in the honeymoon phase with AJAX
> > overlook or ignore).
>
> > We're also in the process of developing an ExtJS Form Helper that will
> > translate Cake's built-in validation rules to client side equivalents
> > to further tighten up the client-side experience.
>
> > Another thing people commonly misunderstand about MVC - or at least
> > take too literally - is the idea that each controller has to operate
> > on a single model. I reject that notion entirely - we organize our
> > controllers by logical functionality. For instance, we have a
> > controller that deals entirely with account related operations. We
> > don't have a table called accounts, and that controller operates on
> > half a dozen models. This makes the URLs more logical for the end-user
> > and it's much easier to maintain from a developer's standpoint, AND
> > makes it easier to divide up work amongst a team of developers.
>
> > Like Nate mentioned, this is not an MVC problem at all, just an
> > integration problem.
>
> > I hope to share a lot of the knowledge we've gained developing this
> > application on the Bakery at some point.
>
> > Good luck,
> > James
>
> > On Nov 30, 9:00 am, wirtsi <florian.kra...@googlemail.com> wrote:
>
> > > Hey guys
>
> > > I've been developing web applications with Cake for almost 2 years
> > > and  I never want go back to the old vile php ways again.
>
> > > I must say that with more advanced applications the MVC concept isn't
> > > working so good any more. With any halfway decent webapp you will have
> > > a lot of controller logic in the views, namely all those JavaScript
> > > functions you use.
>
> > > For example: Passing form field values to the server via ajax calls
> > > for validation or opening modal windows over content items (ie context
> > > menus etc)
>
> > > If you take JavaScript even a step further then you'll end up with
> > > frameworks like ExtJS ... you don't write a single line of HTML code
> > > anymore, just the body. The framework then will insert all the lists,
> > > menus or whatever you want onto the canvas and populate them with data
> > > it gets from the server via json.
>
> > > Working with Cake this gets really ugly .. because then you will end
> > > up with redundant code, data validation on the server side but also on
> > > the client.
>
> > > Yesterday I read an article on this issue (http://advogato.org/article/
> > > 993.html) ... it's a bit strong anti-PHP but it hits the spot. It goes
> > > on about combining a MVC framework (Web2Py) with a Python-to-
> > > Javascript compiler (Pyjamas) which in the end will result in coding
> > > in Python and having a framework do all the html work .. so like Ext
> > > but with a proper server-side backend.
>
> > > What also would solve the problem of code redundancy is a JS framework
> > > like TrimPath  (http://code.google.com/p/trimpath/wiki/TrimJunction)
> > > where you only code in JS and the same code gets executed on the
> > > server and the client ... BUT ... do we really want to code ours apps
> > > in JavaScript? I for sure don't want to.
>
> > > So I had this idea yesterday how to solve this problem at least
> > > partly .. by partly I mean at least all the data validation.
>
> > > Develop a doped up form helper. Said form helper gets the validation
> > > rules for every field from the model and implements the JavaScript
> > > rules automatically ... on the server side everything stays the same.
>
> > > For examle if field "name" has the NOT_EMPTY validation rule, the
> > > DopeFormHelper could add this validation to the view so even before
> > > submitting to the server the user gets notified of his mistake.
>
> > > What I'm not quite sure of is ... am I breaking all the MVC rules
> > > thinking like this? AFAIK the view (and therefore the Helper as well)
> > > should have no knowledge of any model rules or code. How do I get
> > > these informations in there?
>
> > > So what do the gurus think of this? Any ideas how to keep all that JS
> > > code out of our views?
>
> > > Enjoy your weekends
>
> > > wirtsi
--~--~---------~--~----~------------~-------~--~----~
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: Copied cake PHP files to a new Ubuntu Intrepid box and nothing is working


Are you sure you have sufficient php modules installed with ubuntu package manager?

I would compare your phpinfo() on the original box versus the new box(), or even just have a look at what is ticked related to php on synaptic package manager. If I saw that error message I'd be looking at libraries straight away.

You may not get everything you think you ought to by default.



On Sun, Nov 30, 2008 at 5:52 AM, Nick <nlofaso@gmail.com> wrote:

I'm desperate for some help here...  I just built a brand new ubuntu
intrepid server and copied everything from my cake folders on my
Ubuntu Hardy box to the new intrepid server.

If I extract a fresh version of Cake, everything works fine, css shows
up, db calls work correctly, etc., but everything is failing when I
copy all my work over.

I see no CSS formatting and I get the following error:

Fatal error: Call to undefined function mysql_connect() in /home/phazo/
Dropbox/www/lymtest3/cake/libs/model/datasources/dbo/dbo_mysql.php on
line 117

I've dumped my sql database and imported it on the new device
triple checked the sql accounts
made sure my tmp directory is writeable
enabled MOD rewrites
verified my .htaccess files exist
set "AllowOverride all" for my directories in the apache2.conf file

what else could I be missing?
Thanks for any help anyone can provide!



--~--~---------~--~----~------------~-------~--~----~
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: controller fixturize drops table in end, how to test data?

maybe you could overwrite the endController method, and then check for
the result to finish the test case method.


var $result;

function endController(&$controller, $params = array()) {
$this->result = $controller->Model->find("all");

return parent::endController($controller, $params);
}

function testMyAction() {
....
....
$this->assertEqual($this->result, $expected);
}

--~--~---------~--~----~------------~-------~--~----~
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: how to translate the pagination words: "next" and "previous"

i found another easy way to translate the two words: "next" and
"previous" , simply by passing the arabic word to the function as an
argument:

$paginator->prev("السابق");
$paginator->next("التالي");


On Nov 29, 6:05 pm, "Federico Rinaldi" <federicorina...@gmail.com>
wrote:
> You should use Localization:
>
> http://book.cakephp.org/view/162/Localizing-Your-Application
>
> And internationalization
>
> http://book.cakephp.org/view/163/Internationalization-in-CakePHP
>
> Regards,
>
> FedeX
>
> On Sat, Nov 29, 2008 at 10:07 AM, ahmed sabrah <ahmedhelmy...@gmail.com>wrote:
>
>
>
>
>
> > i'm new to cakePHP, and i need the pagination words : "next" and
> > "previous" to be translated into arabic.
> > should i search for an arabic language translation for the cakePHP ?
> > and if that is the case, can any one tell me where to download it ?
>
> > sorry for my bad english.- 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: Copied cake PHP files to a new Ubuntu Intrepid box and nothing is working

I've traced the issue to the database.php file.

If this file doesn't exist, then the CSS renders correctly.

If this file exists, then everything goes haywire. This happens
whether I add the correct mysql login data or bogus data.

There is a difference between the versions of mysql between the two
boxes:

Old: 5.0.51a-3ubuntu5.4 (Ubuntu)
New: 5.0.67-0ubuntu6 (Ubuntu)

Anyone know of any issues with the new version of MySql or Ubuntu?

On Nov 30, 12:52 am, Nick <nlof...@gmail.com> wrote:
> I'm desperate for some help here...  I just built a brand new ubuntu
> intrepid server and copied everything from my cake folders on my
> Ubuntu Hardy box to the new intrepid server.
>
> If I extract a fresh version of Cake, everything works fine, css shows
> up, db calls work correctly, etc., but everything is failing when I
> copy all my work over.
>
> I see no CSS formatting and I get the following error:
>
> Fatal error: Call to undefined function mysql_connect() in /home/phazo/
> Dropbox/www/lymtest3/cake/libs/model/datasources/dbo/dbo_mysql.php on
> line 117
>
> I've dumped my sql database and imported it on the new device
> triple checked the sql accounts
> made sure my tmp directory is writeable
> enabled MOD rewrites
> verified my .htaccess files exist
> set "AllowOverride all" for my directories in the apache2.conf file
>
> what else could I be missing?
> Thanks for any help anyone can provide!
--~--~---------~--~----~------------~-------~--~----~
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: how to translate the pagination words: "next" and "previous"

thanx very much FedeX .

On Nov 29, 6:05 pm, "Federico Rinaldi" <federicorinaldi@gmail.com>
wrote:
> You should use Localization:
>
> http://book.cakephp.org/view/162/Localizing-Your-Application
>
> And internationalization
>
> http://book.cakephp.org/view/163/Internationalization-in-CakePHP
>
> Regards,
>
> FedeX
>
> On Sat, Nov 29, 2008 at 10:07 AM, ahmed sabrah <ahmedhelmy007@gmail.com>wrote:
>
>
>
>
>
> > i'm new to cakePHP, and i need the pagination words : "next" and
> > "previous" to be translated into arabic.
> > should i search for an arabic language translation for the cakePHP ?
> > and if that is the case, can any one tell me where to download it ?
>
> > sorry for my bad english.- 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: Understanding if a model-controller couple is needed

The answer as always is "it depends" (but in this case I think the
answer is yes you need a model for the review).

First I would suggest that your movies_reviewers might be named
reviews, since it sounds like that is what you're putting in it.

If you will be accessing data from the review, then you need a model
for it. Personally I tend to model the relationships of all of the
tables using "cake bake", then go back and make sure all the
relationships are reflected in the models that I will be driving my UI
with.

Are your relationships really HABTM, or are they parent-child? I would
think that you'd have:

1. Movies has many Reviews
2. Reviewers has many Reviews
3. Reviews belong to Movies and Reviewers

On Nov 29, 11:43 am, Fabio M <fabio.mess...@gmail.com> wrote:
> Hi all. This is my first message here.
> I want to make it clear first that I read the (almost) whole
> documentation and now I'm going to develop a first application. I
> still have a doubt about dealing with HABTM relationship.
>
> I give you the precise picture.
>
> I have two entities: movie (motion picture) and reviewer. These are in
> a HABTM relationship, which represents the review. I'll create the
> conventional db tables: movies, reviewers and movies_reviewers. Note
> that movies_reviewers isnt just a join-table, it includes other
> informations beyond the foreign key (the vote of the review, the text
> of the review).
>
> Now I ask: do I need a model for the review? Is the review an object
> in my application?
>
> If so, which table should this model class be linked to? Directly to
> join-table?
>
> Should I make a whole another design? Dont know...  with three
> entities (movie, review, reviewers) and two merely associative
> relationships (with a movie_id and a reviewer_id in the reviews
> table)?
>
> Thank you. And forgive me for bad explanation and for not having found
> this topic in other threads. I'm italian and I'm a bit in difficulty
> at retrieving technical infos in a foreign language.
>
> Thank you in advance.  : )
>
>                       Fabio M
--~--~---------~--~----~------------~-------~--~----~
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: total newbie - Config question

DO NOT PUT CAKEPHP IN PUBLIC_HTML! I have hostgator as well, this is
what you do put it above public_html so it will not be accessible by
anyone. Then take webroot folder out of the app folder which is inside
the cake folder, and upload it to your public html, or if the cakeapp
is going to be your site just upload the contents of webroot folder to
public_html. Then edit index.php in your webroot folder that you have
just added to public_html and change these 2 lines

if (!defined('ROOT')) {
define('ROOT', DS.'home'.DS.'YOUR HOSTGATOR USERNAME'.DS.'CakePHP');
}

and if you have changed the app folder name from app to something else
then change this line too
if (!defined('APP_DIR')) {
define('APP_DIR', 'APP FOLDER NAME');
}

On Nov 30, 10:01 am, rgreenphotodesign <rgr...@rgreenphotography.com>
wrote:
> Do you have your domain home directory/doc root pointed to /possible
> sub dir/app/webroot/?
>
> On Nov 29, 7:49 pm, scott <scottpowe...@gmail.com> wrote:
>
> > Hello all,
>
> > Just started learning CakePHP and am excited at the possibilities, but
> > have hit my first snag.
>
> > This is my first post and have read the documentation, but cannot find
> > the solution to my problem.
>
> > I uploaded the full cake package to my server into the root directory
> > which is public_html. I'm using Hostgator which has php 5 and
> > mod_rewrite activated.
>
> > I can only get the home page to show up when I set ReWriteEngine  to
> > "off". If it is on, I get 404 not found.
>
> > Also, I don't know if this is a problem, but I don't have an active
> > domain pointed to it. So I access the root directory bywww.mainserverexample.com/~cake
>
> > Thanks in advance for your help,
>
> > Scott
--~--~---------~--~----~------------~-------~--~----~
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: Self contained css in Cake's default app

I'm no expert, but I generally tend to create a one page/style sheet
in something like Dreamweaver. I'll try to cover as many of the block
level elements I'll need so I can have as simple of mark up in my
views. Then I just plop the CSS in and am off to the bakery.

On Nov 29, 7:46 pm, "Federico Rinaldi" <federicorina...@gmail.com>
wrote:
> The idea is to bring the legacy app, to cake. I know there are some choices
> but I think the cleanest it's to self contain cake classes. If just do not
> use generic css in the app I will have to RE create all the classes for the
> cake views again (not so much DRY I think, as generic should already have
> those).
>
> FedeX
>
> On Sun, Nov 30, 2008 at 12:21 AM, mark_story <mark.st...@gmail.com> wrote:
>
> > Could just not use the generic css on an already started app?
>
> > -Mark
>
> > On Nov 29, 2:52 pm, "Federico Rinaldi" <federicorina...@gmail.com>
> > wrote:
> > > Hi guys, I just wanted to ask what do you think about the css that comes
> > by
> > > default in a cake's application. As far as I can tell it is very helpfull
> > as
> > > it provides you a way to rapidly change the layout of your app but some
> > > times it's a real pain as it chages the base style for almost every html
> > > entity.
> > > I think that with new apps that's not an issue but if you have to merge
> > it
> > > with some kind of legacy code then you will have to override each and
> > every
> > > one of those entities styles.
>
> > > So my proposal is that the cake.generic.css contains all of the styles
> > self
> > > contained (ie in classes or pointing to specific element's ids).
>
> > > What do you think of that?
--~--~---------~--~----~------------~-------~--~----~
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: How to validate and update password of a user with affecting HABTM relations for the user?

if you have the auth component added, then password field will be
hashed automatically, the hashing happens before validation and thus
your validation rules, except for your password compare, will never
work.
http://teknoid.wordpress.com/2008/10/08/demystifying-auth-features-in-cakephp-12/
check that out should show you what to do to fix that.

For using validation from controller you must set it to the model
first
http://book.cakephp.org/view/410/Validating-Data-from-the-Controller


On Nov 30, 9:52 am, Milmar <milmarq...@gmail.com> wrote:
> I tried $this->Model->validate() in the controller, but for some
> reason, 'password' and 'password_confirm' are not being passed to the
> Model (I tried logging them in the "beforeValidate()" callback).
> Do you have some sample code where I can see how to use $this->Model-
>
> >validate() for editing the password?
>
> Thanks.
>
> On Dec 1, 1:36 am, thatsgreat2345 <thatsgreat2...@gmail.com> wrote:
>
> > You can validate from the controller using $this->Model->validate();
>
> > On Nov 30, 9:27 am, Milmar <milmarq...@gmail.com> wrote:
>
> > > I was able to solve this by first using $this->User->save($this->data)
> > > so that I can validate the fields in the model.
> > > Then switching to the "saveField" function in the Model's "beforeSave
> > > ()" callback so that the save would not affect the HABTM relations.
> > > Here's the code for "beforeSave()":
>
> > > function beforeSave() {
> > >          //If operation is save and this is an edit(has ID,password,
> > > and password_confirm),
> > >          //   use the saveField command to save the password
> > >          if(isset($this->data[$this->alias]['password']) && isset
> > > ($this->data[$this->alias]['id']) &&
> > >             isset($this->data[$this->alias]['password_confirm']))
> > >          {
> > >             return $this->saveField('password',$this->data[$this->alias]['password']);
>
> > >          }
>
> > >          $this->hashPasswords(null, true);
> > >          return true;
>
> > > }
--~--~---------~--~----~------------~-------~--~----~
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: total newbie - Config question

Do you have your domain home directory/doc root pointed to /possible
sub dir/app/webroot/?

On Nov 29, 7:49 pm, scott <scottpowe...@gmail.com> wrote:
> Hello all,
>
> Just started learning CakePHP and am excited at the possibilities, but
> have hit my first snag.
>
> This is my first post and have read the documentation, but cannot find
> the solution to my problem.
>
> I uploaded the full cake package to my server into the root directory
> which is public_html. I'm using Hostgator which has php 5 and
> mod_rewrite activated.
>
> I can only get the home page to show up when I set ReWriteEngine  to
> "off". If it is on, I get 404 not found.
>
> Also, I don't know if this is a problem, but I don't have an active
> domain pointed to it. So I access the root directory bywww.mainserverexample.com/~cake
>
> Thanks in advance for your help,
>
> Scott
--~--~---------~--~----~------------~-------~--~----~
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: Cake Bake Fatal error in Linux

This has nothing to do with CakePHP. You need to sort out your MySQL installation,
first. The error you're seeing is, again, quite common. Google will show you the way.

On Sun, Nov 30, 2008 at 8:57 AM, nithinalex <nithinga@gmail.com> wrote:

Now I am getting a new error...

Warning: mysql_connect(): Can't connect to local MySQL server through
socket '/var/run/mysqld/mysqld.sock' (2) in /usr/share/php/cake1.2/
libs/model/datasources/dbo/dbo_mysql.php on line 100

I am getting confused....I installed php cli,Cake1.2 Scripts,php5-
mysql...( Working in Xampp environment in ubuntu )

I am getting the above error when i try to bake model,controllers &
views...only able to configure database.

Can anyone tell how to configure Cake Bake in Ubuntu under Xampp
Environment.




brian wrote:
> It appears that you do not have the PHP MySQL libs installed.
>
> *apt*-get install php-*mysql*
>
> On Sat, Nov 29, 2008 at 10:21 AM, nithinalex <nithinga@gmail.com> wrote:
>
> >
> > Hello Friends
> >
> >   When i am using Cake Bake I am getting an error like this...
> >
> > Fatal error: Call to undefined function mysql_connect() in /usr/share/
> > php/cake1.2/libs/model/datasources/dbo/dbo_mysql.php on line 100
> >
> > I am using XAMPP, Cake 1.2 in Ubuntu.
> >
> >
> > >
> >



--~--~---------~--~----~------------~-------~--~----~
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: How to validate and update password of a user with affecting HABTM relations for the user?

I tried $this->Model->validate() in the controller, but for some
reason, 'password' and 'password_confirm' are not being passed to the
Model (I tried logging them in the "beforeValidate()" callback).
Do you have some sample code where I can see how to use $this->Model-
>validate() for editing the password?

Thanks.


On Dec 1, 1:36 am, thatsgreat2345 <thatsgreat2...@gmail.com> wrote:
> You can validate from the controller using $this->Model->validate();
>
> On Nov 30, 9:27 am, Milmar <milmarq...@gmail.com> wrote:
>
> > I was able to solve this by first using $this->User->save($this->data)
> > so that I can validate the fields in the model.
> > Then switching to the "saveField" function in the Model's "beforeSave
> > ()" callback so that the save would not affect the HABTM relations.
> > Here's the code for "beforeSave()":
>
> > function beforeSave() {
> >          //If operation is save and this is an edit(has ID,password,
> > and password_confirm),
> >          //   use the saveField command to save the password
> >          if(isset($this->data[$this->alias]['password']) && isset
> > ($this->data[$this->alias]['id']) &&
> >             isset($this->data[$this->alias]['password_confirm']))
> >          {
> >             return $this->saveField('password',$this->data[$this->alias]['password']);
>
> >          }
>
> >          $this->hashPasswords(null, true);
> >          return true;
>
> > }
--~--~---------~--~----~------------~-------~--~----~
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: update related model data

Did you try setting $this->User->UserProfile->id to the id of the
userprofile to be edited? (I'm not really sure about this since I've
never used "saveAll").

Maybe:

$userprofileid = $this->User->UserProfile->find(array('user_id' =>
$this->data['User']['id']),array('id'));
$this->User->UserProfile->id = $userprofileid['UserProfile']['id'];
$this->User->saveAll($this->data);

On Nov 30, 3:02 am, lacithetemplar <lacithetemp...@gmail.com> wrote:
> hello,
> I have two tables "users" and "user_profiles", which are related .
> there's no problem to add new data to this tables, but I don't know
> how to edit/update this data. when I use $this->User->saveAll($this->data), it updates users table, but in the user_profiles it add a new
>
> entry instead of update current entry. have someone a solution?
> 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: How to validate and update password of a user with affecting HABTM relations for the user?

You can validate from the controller using $this->Model->validate();

On Nov 30, 9:27 am, Milmar <milmarq...@gmail.com> wrote:
> I was able to solve this by first using $this->User->save($this->data)
> so that I can validate the fields in the model.
> Then switching to the "saveField" function in the Model's "beforeSave
> ()" callback so that the save would not affect the HABTM relations.
> Here's the code for "beforeSave()":
>
> function beforeSave() {
>          //If operation is save and this is an edit(has ID,password,
> and password_confirm),
>          //   use the saveField command to save the password
>          if(isset($this->data[$this->alias]['password']) && isset
> ($this->data[$this->alias]['id']) &&
>             isset($this->data[$this->alias]['password_confirm']))
>          {
>             return $this->saveField('password',$this->data[$this->alias]['password']);
>
>          }
>
>          $this->hashPasswords(null, true);
>          return true;
>
> }
--~--~---------~--~----~------------~-------~--~----~
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: How to validate and update password of a user with affecting HABTM relations for the user?

I was able to solve this by first using $this->User->save($this->data)
so that I can validate the fields in the model.
Then switching to the "saveField" function in the Model's "beforeSave
()" callback so that the save would not affect the HABTM relations.
Here's the code for "beforeSave()":

function beforeSave() {
//If operation is save and this is an edit(has ID,password,
and password_confirm),
// use the saveField command to save the password
if(isset($this->data[$this->alias]['password']) && isset
($this->data[$this->alias]['id']) &&
isset($this->data[$this->alias]['password_confirm']))
{
return $this->saveField('password',$this->data[$this-
>alias]['password']);
}

$this->hashPasswords(null, true);
return true;
}
--~--~---------~--~----~------------~-------~--~----~
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: MVC falling to pieces for modern AJAX apps

James, that ExtHelper of yours would truly be very interesting to
me ... I've been wrapping my head around Ext the last few weeks and I
really like the possibilities it gives you creating spot on user
interfaces .. I just found it a massive pain to get the data over from
Cake, especially with 1:n or n:m relationships which I more or less
had to put back together by hand in ext (because I had to flatten the
data output list to one level) but then perhaps I haven't quite
grasped all that DataReader stuff yet.

I really like the idea just using a form submit to validate the
data ... I was thinking along the lines of per field ajax submit &
validate (like you see in the ext demos .. field is empty, ext
complains about it right away) but what the heck, this seems so much
easier :). Do you validate only after a user submits (via ajax) or do
you submit periodically to display errors on the fly? In latter case I
could image one could get quite a few duplicate entries if the user
happens to fill out all the fields correctly.

But to get back to my original post, how would it sound if Cake
allowed for user defined JavaScript functions in the model definition.
For example "name" NOT_EMPTY but also "alert('Must not be empty') so
the server checks the field on submit (in case anyone was fiddling
around with the post data) but the javascript function gets pushed
through to the view.

Ok, that would be having view code in the model but on the other hand
this code is definitely related to the models data.

Thanks for your input

wirtsi

On 30 Nov., 16:07, James K <james.m.k...@gmail.com> wrote:
> Strongly disagree.
>
> I'm in the middle of a massive CakePHP/ExtJS development and it works
> like a dream (To date: 40 controllers, 89 models). A lot of our
> controller actions simply return JSON. Cake is perfectly suited to
> this. Grab your data, do some set::extract manipulation on it if
> necessary, and use the object method of the javascript helper to send
> it to the client as JSON.
>
> Also you should ALWAYS validate your data on the server side. Client
> side validation is not reliable or secure. You can add it in as a
> slight convenience to the user, but your application should never ever
> rely on client side validation to do its job.
>
> The technique we're currently using is we load Cake's forms into ExtJS
> panels that proceed to digest the DOM elements (configure the form in
> Ext, set the contentEl properties of the different panels to the ids
> of the divs or fieldsets generated by cake) and then submit them via
> AJAX back to the server. When the panel comes back, it has Cake's
> validation messages next to the appropriate fields. This technique
> also allows us to leverage the added security of the Security
> component to ensure that no one's using Firebug or something similar
> to allow them to submit data they aren't supposed to (which is a major
> security risk a lot of developers in the honeymoon phase with AJAX
> overlook or ignore).
>
> We're also in the process of developing an ExtJS Form Helper that will
> translate Cake's built-in validation rules to client side equivalents
> to further tighten up the client-side experience.
>
> Another thing people commonly misunderstand about MVC - or at least
> take too literally - is the idea that each controller has to operate
> on a single model. I reject that notion entirely - we organize our
> controllers by logical functionality. For instance, we have a
> controller that deals entirely with account related operations. We
> don't have a table called accounts, and that controller operates on
> half a dozen models. This makes the URLs more logical for the end-user
> and it's much easier to maintain from a developer's standpoint, AND
> makes it easier to divide up work amongst a team of developers.
>
> Like Nate mentioned, this is not an MVC problem at all, just an
> integration problem.
>
> I hope to share a lot of the knowledge we've gained developing this
> application on the Bakery at some point.
>
> Good luck,
> James
>
> On Nov 30, 9:00 am, wirtsi <florian.kra...@googlemail.com> wrote:
>
> > Hey guys
>
> > I've been developing web applications with Cake for almost 2 years
> > and  I never want go back to the old vile php ways again.
>
> > I must say that with more advanced applications the MVC concept isn't
> > working so good any more. With any halfway decent webapp you will have
> > a lot of controller logic in the views, namely all those JavaScript
> > functions you use.
>
> > For example: Passing form field values to the server via ajax calls
> > for validation or opening modal windows over content items (ie context
> > menus etc)
>
> > If you take JavaScript even a step further then you'll end up with
> > frameworks like ExtJS ... you don't write a single line of HTML code
> > anymore, just the body. The framework then will insert all the lists,
> > menus or whatever you want onto the canvas and populate them with data
> > it gets from the server via json.
>
> > Working with Cake this gets really ugly .. because then you will end
> > up with redundant code, data validation on the server side but also on
> > the client.
>
> > Yesterday I read an article on this issue (http://advogato.org/article/
> > 993.html) ... it's a bit strong anti-PHP but it hits the spot. It goes
> > on about combining a MVC framework (Web2Py) with a Python-to-
> > Javascript compiler (Pyjamas) which in the end will result in coding
> > in Python and having a framework do all the html work .. so like Ext
> > but with a proper server-side backend.
>
> > What also would solve the problem of code redundancy is a JS framework
> > like TrimPath  (http://code.google.com/p/trimpath/wiki/TrimJunction)
> > where you only code in JS and the same code gets executed on the
> > server and the client ... BUT ... do we really want to code ours apps
> > in JavaScript? I for sure don't want to.
>
> > So I had this idea yesterday how to solve this problem at least
> > partly .. by partly I mean at least all the data validation.
>
> > Develop a doped up form helper. Said form helper gets the validation
> > rules for every field from the model and implements the JavaScript
> > rules automatically ... on the server side everything stays the same.
>
> > For examle if field "name" has the NOT_EMPTY validation rule, the
> > DopeFormHelper could add this validation to the view so even before
> > submitting to the server the user gets notified of his mistake.
>
> > What I'm not quite sure of is ... am I breaking all the MVC rules
> > thinking like this? AFAIK the view (and therefore the Helper as well)
> > should have no knowledge of any model rules or code. How do I get
> > these informations in there?
>
> > So what do the gurus think of this? Any ideas how to keep all that JS
> > code out of our views?
>
> > Enjoy your weekends
>
> > wirtsi
--~--~---------~--~----~------------~-------~--~----~
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: Copied cake PHP files to a new Ubuntu Intrepid box and nothing is working

I've traced the issue to something with my

On Nov 30, 12:52 am, Nick <nlof...@gmail.com> wrote:
> I'm desperate for some help here...  I just built a brand new ubuntu
> intrepid server and copied everything from my cake folders on my
> Ubuntu Hardy box to the new intrepid server.
>
> If I extract a fresh version of Cake, everything works fine, css shows
> up, db calls work correctly, etc., but everything is failing when I
> copy all my work over.
>
> I see no CSS formatting and I get the following error:
>
> Fatal error: Call to undefined function mysql_connect() in /home/phazo/
> Dropbox/www/lymtest3/cake/libs/model/datasources/dbo/dbo_mysql.php on
> line 117
>
> I've dumped my sql database and imported it on the new device
> triple checked the sql accounts
> made sure my tmp directory is writeable
> enabled MOD rewrites
> verified my .htaccess files exist
> set "AllowOverride all" for my directories in the apache2.conf file
>
> what else could I be missing?
> Thanks for any help anyone can provide!
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

How to validate and update password of a user with affecting HABTM relations for the user?

I have the following code for my "reset user password" administrator
page:

<div class="users form">
<?php echo $form->create('User',array('action' => 'resetpassword'));?>
<?php echo $html->link('Back',array('action' => 'edit',$id)); ?>
<fieldset>
<legend><?php echo 'Reset password for ' . $username['User']
['username'];?></legend>
<?php
echo $form->input('id',array('value'=>$id));
echo $form->input('password',array('label'=>'New Password'));
echo $form->input('password_confirm',array
('type'=>'password','label'=>'Confirm Password'));
echo $form->submit('Submit');
echo $form->button('Reset',array('type' => 'reset'));
echo $form->end();
?>
</fieldset>
<?php echo $html->link('Back',array('action' => 'edit',$id)); ?>
</div>


...then for the Users controller:

function resetpassword($id = null)
{
if (!$id && empty($this->data)) {
$this->Session->setFlash('Invalid User', true);
}
else if (!empty($this->data)) {
$this->User->id = $this->data['User']['id'];
$this->set('id',$this->data['User']['id']);
$username = $this->User->read('username',$this->data['User']
['id']);
$this->set('username',$username);
if($this->User->save($this->data))
{
$this->Session->setFlash('You have successfully reset the
password.');
}
else
{
$this->Session->setFlash('Failed to reset password.
Please try again.');
}
}
else if (empty($this->data)) {
$username = $this->User->read('username', $id);
$this->set('username',$username);
$this->set('id',$id);
}
}

As you can see in the Users controller, I need to call $this->User-
>save($this->data) so that I can send both 'password' and
'password_confirm' to the User model where the validation is
performed.

My validation rules in the User model is as follows:

var validate = array(
'password' => array
(
array('rule'=>array
('passwordCompare','password_confirm'),'message'=>''),
array('rule'=>array('minLength',4),'message'=>'Password
must have at least 4 characters.'),
array('rule'=>array('notEmpty'),'message'=>'Password
cannot be empty.'),
)
);

...where "passwordCompare" is defined to check if 'password' and
'password_confirm' are equal before saving the field in the DB.

My problem is that "Users" is also connected via an HABTM relation to
a "Roles" table, so, when I call $this->User->save($this->data) above,
my existing HABTM relations are getting deleted. I'm suspecting it's
because $this->data only contains data that was in my "reset" form
(password, and password_confirm), but cake requires that the HABTM
relations should be there too (maybe via hidden fields?). My first
idea to fix this was to perform the validation in the controller then
just use the "saveField" function so that I'm sure that only the
password field is being modified.

Question: Is there a way where I can still implement validation in the
model without affecting the HABTM relations???
--~--~---------~--~----~------------~-------~--~----~
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: MVC falling to pieces for modern AJAX apps

Strongly disagree.

I'm in the middle of a massive CakePHP/ExtJS development and it works
like a dream (To date: 40 controllers, 89 models). A lot of our
controller actions simply return JSON. Cake is perfectly suited to
this. Grab your data, do some set::extract manipulation on it if
necessary, and use the object method of the javascript helper to send
it to the client as JSON.

Also you should ALWAYS validate your data on the server side. Client
side validation is not reliable or secure. You can add it in as a
slight convenience to the user, but your application should never ever
rely on client side validation to do its job.

The technique we're currently using is we load Cake's forms into ExtJS
panels that proceed to digest the DOM elements (configure the form in
Ext, set the contentEl properties of the different panels to the ids
of the divs or fieldsets generated by cake) and then submit them via
AJAX back to the server. When the panel comes back, it has Cake's
validation messages next to the appropriate fields. This technique
also allows us to leverage the added security of the Security
component to ensure that no one's using Firebug or something similar
to allow them to submit data they aren't supposed to (which is a major
security risk a lot of developers in the honeymoon phase with AJAX
overlook or ignore).

We're also in the process of developing an ExtJS Form Helper that will
translate Cake's built-in validation rules to client side equivalents
to further tighten up the client-side experience.

Another thing people commonly misunderstand about MVC - or at least
take too literally - is the idea that each controller has to operate
on a single model. I reject that notion entirely - we organize our
controllers by logical functionality. For instance, we have a
controller that deals entirely with account related operations. We
don't have a table called accounts, and that controller operates on
half a dozen models. This makes the URLs more logical for the end-user
and it's much easier to maintain from a developer's standpoint, AND
makes it easier to divide up work amongst a team of developers.

Like Nate mentioned, this is not an MVC problem at all, just an
integration problem.

I hope to share a lot of the knowledge we've gained developing this
application on the Bakery at some point.

Good luck,
James

On Nov 30, 9:00 am, wirtsi <florian.kra...@googlemail.com> wrote:
> Hey guys
>
> I've been developing web applications with Cake for almost 2 years
> and  I never want go back to the old vile php ways again.
>
> I must say that with more advanced applications the MVC concept isn't
> working so good any more. With any halfway decent webapp you will have
> a lot of controller logic in the views, namely all those JavaScript
> functions you use.
>
> For example: Passing form field values to the server via ajax calls
> for validation or opening modal windows over content items (ie context
> menus etc)
>
> If you take JavaScript even a step further then you'll end up with
> frameworks like ExtJS ... you don't write a single line of HTML code
> anymore, just the body. The framework then will insert all the lists,
> menus or whatever you want onto the canvas and populate them with data
> it gets from the server via json.
>
> Working with Cake this gets really ugly .. because then you will end
> up with redundant code, data validation on the server side but also on
> the client.
>
> Yesterday I read an article on this issue (http://advogato.org/article/
> 993.html) ... it's a bit strong anti-PHP but it hits the spot. It goes
> on about combining a MVC framework (Web2Py) with a Python-to-
> Javascript compiler (Pyjamas) which in the end will result in coding
> in Python and having a framework do all the html work .. so like Ext
> but with a proper server-side backend.
>
> What also would solve the problem of code redundancy is a JS framework
> like TrimPath  (http://code.google.com/p/trimpath/wiki/TrimJunction)
> where you only code in JS and the same code gets executed on the
> server and the client ... BUT ... do we really want to code ours apps
> in JavaScript? I for sure don't want to.
>
> So I had this idea yesterday how to solve this problem at least
> partly .. by partly I mean at least all the data validation.
>
> Develop a doped up form helper. Said form helper gets the validation
> rules for every field from the model and implements the JavaScript
> rules automatically ... on the server side everything stays the same.
>
> For examle if field "name" has the NOT_EMPTY validation rule, the
> DopeFormHelper could add this validation to the view so even before
> submitting to the server the user gets notified of his mistake.
>
> What I'm not quite sure of is ... am I breaking all the MVC rules
> thinking like this? AFAIK the view (and therefore the Helper as well)
> should have no knowledge of any model rules or code. How do I get
> these informations in there?
>
> So what do the gurus think of this? Any ideas how to keep all that JS
> code out of our views?
>
> Enjoy your weekends
>
> wirtsi
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---