Thursday, September 30, 2010

Help with foreach

I have my find(‘list’) which gives me my standard array (ordered alphabetically)

 

(

                [16] => apples

                [24] => bananas

                [11] => cars        

[8] => zoo

….

…..

and so on

 

)

 

Now this is where I cant get it the way I need. They become selects in a form so I need them layed out 3 across each row

 

Label  [input]    |     Label  [input]         |     Label  [input]   

 

Next row…..

 

I found a lot of 3 per rows examples online but the problem comes in with adding the foreach ($listItems as $key => $value).

$i = 0;

Sure count the $listitems

$i%$row_count == 0 and build my rows but $i is only adding 1 each time…how do I get key [16] where $i = 0, [24] for 2 and so on….(I need the keys unchanged, I cnnot use 0,1,2,3 as the keys)

 

Any ideas?

 

Re: Is it possible to get a query and display it to views/layouts/default.ctp? Cake 1.3?

Would make far more sense to drop it into an element and pull the element through the layout.



On Thu, Sep 30, 2010 at 10:54 AM, Louie Miranda <lmiranda@gmail.com> wrote:
I got it.

Add the variables on

function beforeFilter() {
        $cartcount = '123';
        $this->set(compact('cartcount'));
    }

on app/app_controller.php

It worked.

--
Louie Miranda
 - Email: lmiranda@gmail.com
 - Web: http://www.louiemiranda.com



On Thu, Sep 30, 2010 at 8:22 AM, Louie Miranda <lmiranda@gmail.com> wrote:
Data variables did not worked when placed on views/layouts/default.ctp?

--
Louie Miranda
 - Email: lmiranda@gmail.com
 - Web: http://www.louiemiranda.com



On Wed, Sep 29, 2010 at 3:54 PM, Jeremy Burns | Class Outfit <jeremyburns@classoutfit.com> wrote:
Put it in an element - in fact your whole cart should be an element.

On 29 Sep 2010, at 08:25, Louie Miranda wrote:

Hi,

I have this shopping cart where I am trying to figure out how can I display a query (example numbers of items on cart) and display it on my views/layouts/default.ctp file?

Image
http://i141.photobucket.com/albums/r50/louiemiranda/debug/shopcart.png

On a normal controller, I would just add this on $this->set. Now, since views/layouts/default.ctp does not have a main controller, how can I propagate date with it?

Any ideas is appreciated.
--
Louie Miranda
 - Email: lmiranda@gmail.com
 - Web: http://www.louiemiranda.com


Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
 
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
 
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en


Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
 
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
 
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

Path problem

Hello,

When I copy and past all cakephp files into htdocs folder and then try
to access http://localhost/cakephp, the default page isn't able to
find the css files and the images that are in the webroot folder. And
I don't understand why because everything seems to be ok in the
configuration...

http://localhost/cakephp = ok
http://localhost/cakephp/img = not found (404)

After, when I create a model posts.php and a controller
posts_controller.php and try to access http://localhost/cakephp/post,
I have an error 404... I though that it can be the rewriting module
that isn't activated but he was. The htaccess are allowed.

Any idea about this problem?

System : Mac OS X 10.6.4
Server : MAMP

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

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

problem deploying cakephp site on the live server ( very strange issue help me)

Hi,

I am using a server that has window package for php. I created my
whole directory structure by Baking script and it made the structure
like

D:\home\username\mydomain.com\
/cake <-cake directory
/config
/controllers
/libs
/locale
/models
/plugins
/tests
/tmp
/vendors
/views
/webroot <-webroot
.htaccess
index.php
app_controller.php
app_helper.php
app_model.php
code-completion-in-views.php

after installed it shows the first default view but it doesnt load up
images , css and even doesnt route any static or non static link.

For static links i made routes like

Router::connect('/', array('controller' => 'pages', 'action' =>
'display', 'home'));

Router::connect('/pages/*', array('controller' => 'pages', 'action'
=> 'display'));

Router::connect('/aboutus', array('controller' => 'pages', 'action'
=> 'display', 'aboutus'));

Router::connect('/features', array('controller' => 'pages', 'action'
=> 'display', 'features'));

the changes i made inside webroot\index file is

if (!defined('ROOT')) {
define('ROOT','D:'. DS.'home'.DS.'username');
}

if (!defined('APP_DIR')) {
define('APP_DIR','mydomain.com');
}

if (!defined('CAKE_CORE_INCLUDE_PATH')) {

define('CAKE_CORE_INCLUDE_PATH','D:'.DS.'home'.DS.'username'.DS.'mydomain.com'.DS.'cake');
}

I tried alot but links , images and css are not working at all, also
on my server they says mode rewrite isnt allowed. Is that is the
problem ??? Do i need to switch on the linux just for this error???


Please help me guys...
Regards

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

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

Re: opening a popup window when clicking on a link

I admit, the error thing was unfortunate ;)

thx for the help...i adapted it....

On 30 Sep., 19:10, cricket <zijn.digi...@gmail.com> wrote:
> On Thu, Sep 30, 2010 at 12:58 PM, Tomfox Wiranata
>
>
>
> <tomfox.wiran...@gmail.com> wrote:
> > thx..i found sth but i am not sure how to proceed.
>
> > I am using the $html->link to open the popup
> >        echo $html->link($user['User']['username']." folgt diesen
> > produkt",array('controller'=>'users', 'action'=>'profile'),
> > array('class'=>'title'));
>
> > when i click this link a jquery function reacts to it because of the
> > class "title" and opens my popup
> > $(document).ready(function() {
>
> >        //When you click on a link with class of poplight and the href starts
> > with a #
> >        $('.title').click(function() {
>
> >                $('.popup_block').fadeIn('fast');
>
> >        });
>
> >        function close(){
> >                $('.popup_block').fadeOut('fast');
> >        }
>
> > });
> > </script>
>
> > due to the current code i get redirected to the view "profile"....but
> > i want this redirection out, gone...
>
> This really has nothing at all to do with Cake. You should study the
> jquery docs or ask on their list. But the gist of it is:
>
> $('.title').click(function(ev) {
>     ev.preventDefault();
>    var href = $(this).attr('href');
>
>     // fetch data from href using AJAX and display in pop-up ...
>
> }
> > and if i do that i get an error...
>
> We're not psychic.
>
> > so how can i open my popup without using a direction in $html-
> >>link?? i like $html->link cause the mouse cursor turns into a hand
> > and makes it transparent to the user, that this is an acutal link
>
> Aside from what I showed above, you can always use the CSS rule,
> "cursor: pointer".

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

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

cakephp dynamic databases.

Hi all,

im developing an application which has the cakephp installed on 1
server and has a login system for customers to connect to their own
databases.

Now my question is, is there an alternative for manualy entering all
customers (1000+) in the database.php config file?

I have all my customers in a local database with all their database
configurations. So my default in my database.php config in cakephp is
the local database with all my customers.

I have done this one time before by having my app_controller do a
beforeFilter() and retrieve the database configurations from my local
database depending on a login + pass. (although, this caused problems
every time..)

Thanks in advance :)

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

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

Best way to handle sub-tabs

I have some tabs along the top of my CakePHP site and some sub-tabs
along the left side of my page. When I switch tabs, it goes to a URL
such as http://system/tabname. When I go to a sub-tab, I use $this-
>render to update the content of the view to what the user clicked
on. However, I'd like a URL such as http://system/tabname/subtab to
go directly to the subtab.

How might I accomplish this? Basically, I want to redirect to tabname/
index and then render the subtab.

My tabname index view sets up the side menu. The subtab just modifies
the inner content. The views/layouts/default.ctp has the top tabs
defined in them. Obviously, the side tabs change from tab to tab.

Hope that makes sense!

Thanks,
Joey

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

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

Odd DESCRIBE issue

Hello all.

I'm running into another odd DESCRIBE issue.

First, even with debug set to 0, CakePHP is running upwards of 60+
DESCRIBE statements. I'm able to confirm this looking at the process
list and logging to queries.

Another issue: In debug mode, I'm seeing this:

57 DESCRIBE `notes` 9 9 1
58 DESCRIBE `reps` 8 8 1
59 DESCRIBE `notes` 9 9 1
60 DESCRIBE `members` 19 19 2
61 DESCRIBE `memberships` 17 17 1
62 DESCRIBE `memberships` 17 17 1
63 DESCRIBE `memberships` 17 17 1

CakePHP is describing the same table multiple times in a row.

Any suggestions?

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

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

Re: Do I need to use sanitize?

I would be careful about using h() instead of htmlspecialchars() it
seems the core guys keep deprecating convenience functions such as a()


On Sep 30, 1:14 pm, euromark <dereurom...@googlemail.com> wrote:
> usually do not clean if after getting it from the DB
> you simply h() encode it. thats a difference.
>
> i depends on the model data
> but if were are in a Comment model and all kinds of comments got
> screwed up
> because the developer was too eager to sanitize every crappy post
> that would piss me off as user.
>
> so especially for aesthetic reasons you are better off leaving the
> post as it is
> if somebody wants to post crap, you can filter all you want, the
> result will still be crap.
> and it will still need to be deleted manually afterwards.
> and all other posts are usally genuine and should be posted as the
> poster intended to.
> of course with h() to ensure nothing happens. but here we go. no
> addiotional work done, no problems.
>
> On 30 Sep., 18:06, "Dave Maharaj" <m...@davemaharaj.com> wrote:
>
>
>
> > Just jumping in here for my opinion, not advise.
>
> > I have seen this question many times, asked it myself along the way and I
> > guess the question asked includes the word "need". And as Dr. Loboto pointed
> > out, you do not need to. But I would like to my 2 cents and even though you
> > may not need to, I personally think of many reasons to do so. For me
> > appearance is key, the last thing I want to see is what appears to be code
> > entered blocks user submitted data. I do not want someone entering <?php
> > echo 'hello'?> as their first name and having that displayed to users.
> > If someone is entering crap info into forms to be a pain in my ass I make it
> > a pain in their ass to try to enter it and make it validate. The only reason
> > someone would enter code or malicious code into would be to try to cause
> > havoc. If they want to try to enter js snips, html blocks with inline
> > attributes go right ahead, I strip it all out beforeValidate(), my own made
> > cleaning functions for specific area of user input. If it takes someone 20
> > attempts to enter their first name because they wrapping it in code, using
> > numbers or symbols then that's just too bad because they obviously know what
> > they are doing they should not be doing. I say 99% would just enter their
> > name as they should. For that 1% of idiots, I would rather not have them use
> > the site so if its hard on them well then too bad.
>
> > Others point out simply let the und users put in what ever they want and
> > clean out all the unwanted stuff once its pulled from the db and displayed
> > to the user. I ask why? Why would you want to have mass amounts of junk code
> > saved in the db only to clean it every time its pulled? Would it not be
> > better off to clean it once and then never worry about it again (until next
> > save).
>
> > So I guess every app has its own unique issues for this question, maybe you
> > do not need to like you asked in the question but for me I think even though
> > it may not be "needed" for security reasons it certainly is for aesthetic
> > reasons.
>
> > Dave
>
> > -----Original Message-----
> > From: WhyNotSmile [mailto:sharongilmor...@gmail.com]
> > Sent: September-30-10 1:10 PM
> > To: CakePHP
> > Subject: Re: Do I need to use sanitize?
>
> > Thanks.
>
> > I'm just sending plain text emails, so that should be fine.
>
> > Sharon
>
> > On 30 Sep, 06:04, "Dr. Loboto" <drlob...@gmail.com> wrote:
> > > I personally never user Sanitize as don't want to break user-entered
> > > data. Instead of it I use h() to escape all text on HTML output. On
> > > save to database also nothing needed as Cake properly escape data
> > > itself. So if you send HTML emails you need just escape user-entered
> > > text and that's all.
>
> > > On Sep 29, 11:43 pm, WhyNotSmile <sharongilmor...@gmail.com> wrote:
>
> > > > I'm creating a website which has a few forms, and wondering whether I
> > > > need to use Sanitize for those.  In each case, there are a few text
> > > > boxes which accept input from visitors; that information gets emailed
> > > > to a central address.  Nothing is stored in the database.
>
> > > > Do I need to use sanitize for that, or is it mainly for times when the
> > > > form data is going into the database?
>
> > > > I also wasn't completely clear on the documentation about sanitize -
> > > > it says Cake automatically uses it for saving and reading, but does
> > > > that include 'find' functions, and do I have to include
> > > > App::import('Sanitize'); to make it work (i.e. it's automatic once
> > > > it's included)?
>
> > > > Thanks!
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp others
> > with their CakePHP related questions.
>
> > You received this message because you are subscribed to the Google Groups
> > "CakePHP" group.
> > To post to this group, send email to cake-php@googlegroups.com
> > To unsubscribe from this group, send email to
> > cake-php+unsubscribe@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php?hl=en

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

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

Re: Facebook & Session Component

The solution: security level in low. But I don't really understand what is happening down there :p.

2010/9/30 Hugo M <ham1988@gmail.com>
Basically, I'm loosing my CakePHP session after using Facebook's multifriend selector... any ideas? :S Is this something related with Cake security??

2010/9/30 Hugo M <ham1988@gmail.com>

Hi! I'm making a FB Connect site. I have a multi-friend selector. When i send invitations, the user is sent to root. Root is albums/index (because there are picture cards albums). Because the application could have only one album, when I just have one album I sent the user straight to that album.

So I have:


    function index() {
        $albums = $this->Album->find('all');

        //If there's only 1 album, we go straight to the album!
        if (count($albums) == 1) {
            $this->choose($albums[0]['Album']['id']);
        }
    }

    function choose($aid) {
        $album = $this->Album->findByIdAndApplicationId($aid,Configure::read('Application.id'));

        if (empty($album)) {
            throw new Exception("Invalid album id");
            //$this->getBack("Invalid album");
        }

        $this->Session->write('Auth.User.album_id', $aid);
        $this->Session->write('Auth.User.album_name',$album['Album']['name']);
        $this->redirect('/albums/view');
    }

function view($page = 1) {
        $uid = $this->Auth->user('user_id');
        $this->loadModel('User');
        $user = $this->User->find('first', array(
            'contain'=>array(
                'Card'
            ),
            'conditions'=>array('User.id'=>$uid)
        ));
        $cardsPerPage = Configure::read('Album.CardsPerPage');
        $offset = ($page-1) * $cardsPerPage;
        if (!$this->Session->check('Auth.User.album_id')) {

//HERE IS THE PROBLEM

                    $this->Session->setFlash("Choose an album");
                    $this->redirect('/albums/');
        }

The problem is that for some reason, this

    $this->Session->write('Auth.User.album_id', $aid);
        $this->Session->write('Auth.User.album_name',$album['Album']['name']);

is lost when I redirect to albums/view, then this code is executed:

   $this->Session->setFlash("Choose an album");
                    $this->redirect('/albums/');

And I have an infinite loop.

Why this could happen? All other Session variables are ok when I do a debug. Only that variables are lost.

This problem appears ONLY when I come from a Facebook callback (like after sending invitations, or clicking in a Facebook link). When I go to /albums/index by myself I am well redirected to albums/view with the only album selected.

I think may have to do with the fact I'm using Auth.User session space to store other fields.... but it's strange it only happens with Facebook.


Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
 
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

Re: Facebook & Session Component

Basically, I'm loosing my CakePHP session after using Facebook's multifriend selector... any ideas? :S Is this something related with Cake security??

2010/9/30 Hugo M <ham1988@gmail.com>
Hi! I'm making a FB Connect site. I have a multi-friend selector. When i send invitations, the user is sent to root. Root is albums/index (because there are picture cards albums). Because the application could have only one album, when I just have one album I sent the user straight to that album.

So I have:


    function index() {
        $albums = $this->Album->find('all');

        //If there's only 1 album, we go straight to the album!
        if (count($albums) == 1) {
            $this->choose($albums[0]['Album']['id']);
        }
    }

    function choose($aid) {
        $album = $this->Album->findByIdAndApplicationId($aid,Configure::read('Application.id'));

        if (empty($album)) {
            throw new Exception("Invalid album id");
            //$this->getBack("Invalid album");
        }

        $this->Session->write('Auth.User.album_id', $aid);
        $this->Session->write('Auth.User.album_name',$album['Album']['name']);
        $this->redirect('/albums/view');
    }

function view($page = 1) {
        $uid = $this->Auth->user('user_id');
        $this->loadModel('User');
        $user = $this->User->find('first', array(
            'contain'=>array(
                'Card'
            ),
            'conditions'=>array('User.id'=>$uid)
        ));
        $cardsPerPage = Configure::read('Album.CardsPerPage');
        $offset = ($page-1) * $cardsPerPage;
        if (!$this->Session->check('Auth.User.album_id')) {

//HERE IS THE PROBLEM

                    $this->Session->setFlash("Choose an album");
                    $this->redirect('/albums/');
        }

The problem is that for some reason, this

    $this->Session->write('Auth.User.album_id', $aid);
        $this->Session->write('Auth.User.album_name',$album['Album']['name']);

is lost when I redirect to albums/view, then this code is executed:

   $this->Session->setFlash("Choose an album");
                    $this->redirect('/albums/');

And I have an infinite loop.

Why this could happen? All other Session variables are ok when I do a debug. Only that variables are lost.

This problem appears ONLY when I come from a Facebook callback (like after sending invitations, or clicking in a Facebook link). When I go to /albums/index by myself I am well redirected to albums/view with the only album selected.

I think may have to do with the fact I'm using Auth.User session space to store other fields.... but it's strange it only happens with Facebook.

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
 
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

Re: Manually set date field using a string "YYYY-MM-DD" does not work?

On Thu, Sep 30, 2010 at 5:46 AM, psybear83 <psybear83@gmail.com> wrote:
> Hi everybody
>
> Take a look at the following code:
>
>    $this->Contract->create($this-
>>getValidDataExcept(array('date'))); // Creates a nearly valid
> contract (only date is missing)
>    debug($this->Contract->field('date')); // (empty) - ok
>    debug($this->Contract->validates()); // 1
>    debug($this->Contract->field('date')); // 2009-09-24 - ok
>    $this->Contract->set('date', '2010-11-11');
>    debug($this->Contract->validates()); // 1
>    debug($this->Contract->field('date')); // 2009-09-24 - not ok!

Model::field() fetches the value from the DB. I think what you want to
be checking is Model::date var. What you've done is manually set the
Contract instance's $date var, then fetched the original value from
the DB (based on the current id).

> Can't I set a date field manually using a string?

Yes. There's nothing wrong with that part.

> And why does the model validate ...

Well, what does your $validation array look like?

> ... and simply ignore my seemingly wrong date input value?
> At least it should complain that date's value is not in a valid
> format, shouldn't it?

Why do you think the date format is wrong?

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

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

Re: Do I need to use sanitize?

usually do not clean if after getting it from the DB
you simply h() encode it. thats a difference.

i depends on the model data
but if were are in a Comment model and all kinds of comments got
screwed up
because the developer was too eager to sanitize every crappy post
that would piss me off as user.

so especially for aesthetic reasons you are better off leaving the
post as it is
if somebody wants to post crap, you can filter all you want, the
result will still be crap.
and it will still need to be deleted manually afterwards.
and all other posts are usally genuine and should be posted as the
poster intended to.
of course with h() to ensure nothing happens. but here we go. no
addiotional work done, no problems.


On 30 Sep., 18:06, "Dave Maharaj" <m...@davemaharaj.com> wrote:
> Just jumping in here for my opinion, not advise.
>
> I have seen this question many times, asked it myself along the way and I
> guess the question asked includes the word "need". And as Dr. Loboto pointed
> out, you do not need to. But I would like to my 2 cents and even though you
> may not need to, I personally think of many reasons to do so. For me
> appearance is key, the last thing I want to see is what appears to be code
> entered blocks user submitted data. I do not want someone entering <?php
> echo 'hello'?> as their first name and having that displayed to users.
> If someone is entering crap info into forms to be a pain in my ass I make it
> a pain in their ass to try to enter it and make it validate. The only reason
> someone would enter code or malicious code into would be to try to cause
> havoc. If they want to try to enter js snips, html blocks with inline
> attributes go right ahead, I strip it all out beforeValidate(), my own made
> cleaning functions for specific area of user input. If it takes someone 20
> attempts to enter their first name because they wrapping it in code, using
> numbers or symbols then that's just too bad because they obviously know what
> they are doing they should not be doing. I say 99% would just enter their
> name as they should. For that 1% of idiots, I would rather not have them use
> the site so if its hard on them well then too bad.
>
> Others point out simply let the und users put in what ever they want and
> clean out all the unwanted stuff once its pulled from the db and displayed
> to the user. I ask why? Why would you want to have mass amounts of junk code
> saved in the db only to clean it every time its pulled? Would it not be
> better off to clean it once and then never worry about it again (until next
> save).
>
> So I guess every app has its own unique issues for this question, maybe you
> do not need to like you asked in the question but for me I think even though
> it may not be "needed" for security reasons it certainly is for aesthetic
> reasons.
>
> Dave
>
> -----Original Message-----
> From: WhyNotSmile [mailto:sharongilmor...@gmail.com]
> Sent: September-30-10 1:10 PM
> To: CakePHP
> Subject: Re: Do I need to use sanitize?
>
> Thanks.
>
> I'm just sending plain text emails, so that should be fine.
>
> Sharon
>
> On 30 Sep, 06:04, "Dr. Loboto" <drlob...@gmail.com> wrote:
> > I personally never user Sanitize as don't want to break user-entered
> > data. Instead of it I use h() to escape all text on HTML output. On
> > save to database also nothing needed as Cake properly escape data
> > itself. So if you send HTML emails you need just escape user-entered
> > text and that's all.
>
> > On Sep 29, 11:43 pm, WhyNotSmile <sharongilmor...@gmail.com> wrote:
>
> > > I'm creating a website which has a few forms, and wondering whether I
> > > need to use Sanitize for those.  In each case, there are a few text
> > > boxes which accept input from visitors; that information gets emailed
> > > to a central address.  Nothing is stored in the database.
>
> > > Do I need to use sanitize for that, or is it mainly for times when the
> > > form data is going into the database?
>
> > > I also wasn't completely clear on the documentation about sanitize -
> > > it says Cake automatically uses it for saving and reading, but does
> > > that include 'find' functions, and do I have to include
> > > App::import('Sanitize'); to make it work (i.e. it's automatic once
> > > it's included)?
>
> > > Thanks!
>
> Check out the new CakePHP Questions sitehttp://cakeqs.organd help others
> with their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups
> "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 athttp://groups.google.com/group/cake-php?hl=en

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

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

Re: opening a popup window when clicking on a link

On Thu, Sep 30, 2010 at 12:58 PM, Tomfox Wiranata
<tomfox.wiranata@gmail.com> wrote:
> thx..i found sth but i am not sure how to proceed.
>
> I am using the $html->link to open the popup
>        echo $html->link($user['User']['username']." folgt diesen
> produkt",array('controller'=>'users', 'action'=>'profile'),
> array('class'=>'title'));
>
>
> when i click this link a jquery function reacts to it because of the
> class "title" and opens my popup
> $(document).ready(function() {
>
>
>
>        //When you click on a link with class of poplight and the href starts
> with a #
>        $('.title').click(function() {
>
>                $('.popup_block').fadeIn('fast');
>
>        });
>
>        function close(){
>                $('.popup_block').fadeOut('fast');
>        }
>
>
> });
> </script>
>
> due to the current code i get redirected to the view "profile"....but
> i want this redirection out, gone...

This really has nothing at all to do with Cake. You should study the
jquery docs or ask on their list. But the gist of it is:

$('.title').click(function(ev) {
ev.preventDefault();
var href = $(this).attr('href');

// fetch data from href using AJAX and display in pop-up ...
}

> and if i do that i get an error...

We're not psychic.

> so how can i open my popup without using a direction in $html-
>>link?? i like $html->link cause the mouse cursor turns into a hand
> and makes it transparent to the user, that this is an acutal link

Aside from what I showed above, you can always use the CSS rule,
"cursor: pointer".

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

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

Re: Prev/Next Record

if you use UUIDs (instead of AIIDs = 0,1,2)
you will need a modified version of that - afaik


On 30 Sep., 17:50, Tilen Majerle <tilen.maje...@gmail.com> wrote:
> i'm sure, that u mean this :D
>
> http://book.cakephp.org/view/1024/find-neighbors
>
> --
> Tilen Majerlehttp://majerle.eu
>
> 2010/9/30 Jeremy Burns | Class Outfit <jeremybu...@classoutfit.com>
>
> > There's probably a way to use pagination with the limit set to 1?
>
> > Jeremy Burns
> > Class Outfit
>
> > jeremybu...@classoutfit.com
> >http://www.classoutfit.com
>
> > On 30 Sep 2010, at 02:09, naidim wrote:
>
> > > For viewing a record, how would one get the record id for the next and
> > > previous records in order to create Next/Previous links?
>
> > > Thanks
>
> > > Check out the new CakePHP Questions sitehttp://cakeqs.organd help
> > others with their CakePHP related questions.
>
> > > You received this message because you are subscribed to the Google Groups
> > "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<cake-php%2Bunsubscribe@googlegroups.com>For more options, visit this group at
> >http://groups.google.com/group/cake-php?hl=en
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others
> > with their CakePHP related questions.
>
> > You received this message because you are subscribed to the Google Groups
> > "CakePHP" group.
> > To post to this group, send email to cake-php@googlegroups.com
> > To unsubscribe from this group, send email to
> > cake-php+unsubscribe@googlegroups.com<cake-php%2Bunsubscribe@googlegroups.com>For more options, visit this group at
> >http://groups.google.com/group/cake-php?hl=en

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

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

Re: Issue getting deeper info

On Thu, Sep 30, 2010 at 11:43 AM, Michael Gaiser <mjgaiser@gmail.com> wrote:
> When I try that is says that Location is not associated with Domain, which
> is correct since the join table is the one associated with both of them.

How about Domain hasMany Location, Location hasMany ChildLocation? And
remove Location hasMany ParentDomains.

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

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

Re: opening a popup window when clicking on a link

thx..i found sth but i am not sure how to proceed.

I am using the $html->link to open the popup
echo $html->link($user['User']['username']." folgt diesen
produkt",array('controller'=>'users', 'action'=>'profile'),
array('class'=>'title'));


when i click this link a jquery function reacts to it because of the
class "title" and opens my popup
$(document).ready(function() {

//When you click on a link with class of poplight and the href starts
with a #
$('.title').click(function() {

$('.popup_block').fadeIn('fast');

});

function close(){
$('.popup_block').fadeOut('fast');
}


});
</script>

due to the current code i get redirected to the view "profile"....but
i want this redirection out, gone...and if i do that i get an
error...so how can i open my popup without using a direction in $html-
>link?? i like $html->link cause the mouse cursor turns into a hand
and makes it transparent to the user, that this is an acutal link

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

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

Re: CakePHP ignores notEmpty validation rule when the field's name is not a key in $data! (Bug or Feature?)

'required' key serves not existent fields, false by default.

var $validate = array(
'name' => array(
'notempty' => array(
'rule' => array('notempty'),
'required' => true // this rule will
fail if data array do not have "name" key
),
),
);

On Sep 30, 7:52 pm, psybear83 <psybea...@gmail.com> wrote:
> Hi everybody
>
> I have baked the following very straight-forward model:
>
> class Post extends AppModel {
>         var $name = 'Post';
>         var $displayField = 'name';
>         var $validate = array(
>                 'name' => array(
>                         'notempty' => array(
>                                 'rule' => array('notempty')
>                         ),
>                 ),
>         );
>
> }
>
> It only needs a value for "name" to be saved.
>
> Now I've written the following 3 tests:
>
>   function testShouldNotBeValidWithEmptyName() {
>     $this->Post->create(array('name' => ''));
>     $this->assertFalse($this->Post->validates());
>   }
>
>   function testShouldNotBeValidWithoutName() {
>     $this->Post->create();
>     $this->assertFalse($this->Post->validates()); // Fails!
>   }
>
>   function testShouldNotBeValidWithNullName() {
>     $this->Post->create(array('name' => null));
>     $this->assertFalse($this->Post->validates());
>   }
>
> I expect all three of them to work, but the 2nd one fails! So why does
> it validate when there truly is no value for the "name" field? Is this
> really the way it should be, or is it a bug?
>
> I'm on version 1.3.4.
>
> Thanks for help
> Josh

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

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

RE: Do I need to use sanitize?

Just jumping in here for my opinion, not advise.

I have seen this question many times, asked it myself along the way and I
guess the question asked includes the word "need". And as Dr. Loboto pointed
out, you do not need to. But I would like to my 2 cents and even though you
may not need to, I personally think of many reasons to do so. For me
appearance is key, the last thing I want to see is what appears to be code
entered blocks user submitted data. I do not want someone entering <?php
echo 'hello'?> as their first name and having that displayed to users.
If someone is entering crap info into forms to be a pain in my ass I make it
a pain in their ass to try to enter it and make it validate. The only reason
someone would enter code or malicious code into would be to try to cause
havoc. If they want to try to enter js snips, html blocks with inline
attributes go right ahead, I strip it all out beforeValidate(), my own made
cleaning functions for specific area of user input. If it takes someone 20
attempts to enter their first name because they wrapping it in code, using
numbers or symbols then that's just too bad because they obviously know what
they are doing they should not be doing. I say 99% would just enter their
name as they should. For that 1% of idiots, I would rather not have them use
the site so if its hard on them well then too bad.

Others point out simply let the und users put in what ever they want and
clean out all the unwanted stuff once its pulled from the db and displayed
to the user. I ask why? Why would you want to have mass amounts of junk code
saved in the db only to clean it every time its pulled? Would it not be
better off to clean it once and then never worry about it again (until next
save).

So I guess every app has its own unique issues for this question, maybe you
do not need to like you asked in the question but for me I think even though
it may not be "needed" for security reasons it certainly is for aesthetic
reasons.

Dave

-----Original Message-----
From: WhyNotSmile [mailto:sharongilmore78@gmail.com]
Sent: September-30-10 1:10 PM
To: CakePHP
Subject: Re: Do I need to use sanitize?

Thanks.

I'm just sending plain text emails, so that should be fine.

Sharon

On 30 Sep, 06:04, "Dr. Loboto" <drlob...@gmail.com> wrote:
> I personally never user Sanitize as don't want to break user-entered
> data. Instead of it I use h() to escape all text on HTML output. On
> save to database also nothing needed as Cake properly escape data
> itself. So if you send HTML emails you need just escape user-entered
> text and that's all.
>
> On Sep 29, 11:43 pm, WhyNotSmile <sharongilmor...@gmail.com> wrote:
>
> > I'm creating a website which has a few forms, and wondering whether I
> > need to use Sanitize for those.  In each case, there are a few text
> > boxes which accept input from visitors; that information gets emailed
> > to a central address.  Nothing is stored in the database.
>
> > Do I need to use sanitize for that, or is it mainly for times when the
> > form data is going into the database?
>
> > I also wasn't completely clear on the documentation about sanitize -
> > it says Cake automatically uses it for saving and reading, but does
> > that include 'find' functions, and do I have to include
> > App::import('Sanitize'); to make it work (i.e. it's automatic once
> > it's included)?
>
> > Thanks!

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

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

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

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

Re: Prev/Next Record

i'm sure, that u mean this :D


--
Tilen Majerle


2010/9/30 Jeremy Burns | Class Outfit <jeremyburns@classoutfit.com>
There's probably a way to use pagination with the limit set to 1?

Jeremy Burns
Class Outfit

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

On 30 Sep 2010, at 02:09, naidim wrote:

> For viewing a record, how would one get the record id for the next and
> previous records in order to create Next/Previous links?
>
> Thanks
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

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

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

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
 
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

Re: Issue getting deeper info

When I try that is says that Location is not associated with Domain, which is correct since the join table is the one associated with both of them.

On Sep 29, 2010 10:46 PM, "wrdevos" <wrdevos@gmail.com> wrote:
> Hi Michael,
>
> take a look at the Containable behavior:
> http://book.cakephp.org/view/1323/Containable
>
> That should fix your problems easy enough.
>
> ~wrdevos
>
> On Sep 30, 4:02 am, Michael Gaiser <mjgai...@gmail.com> wrote:
>> Might this have anything to do with it using the tree behavior?
>> On Sep 29, 2010 7:14 AM, "Michael Gaiser" <mjgai...@gmail.com> wrote:
>>
>>
>>
>> > I will also add that changing the recursive setting does not seem to work.
>>
>> > ~Michael
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
 
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

Re: Do I need to use sanitize?

Thanks.

I'm just sending plain text emails, so that should be fine.

Sharon

On 30 Sep, 06:04, "Dr. Loboto" <drlob...@gmail.com> wrote:
> I personally never user Sanitize as don't want to break user-entered
> data. Instead of it I use h() to escape all text on HTML output. On
> save to database also nothing needed as Cake properly escape data
> itself. So if you send HTML emails you need just escape user-entered
> text and that's all.
>
> On Sep 29, 11:43 pm, WhyNotSmile <sharongilmor...@gmail.com> wrote:
>
> > I'm creating a website which has a few forms, and wondering whether I
> > need to use Sanitize for those.  In each case, there are a few text
> > boxes which accept input from visitors; that information gets emailed
> > to a central address.  Nothing is stored in the database.
>
> > Do I need to use sanitize for that, or is it mainly for times when the
> > form data is going into the database?
>
> > I also wasn't completely clear on the documentation about sanitize -
> > it says Cake automatically uses it for saving and reading, but does
> > that include 'find' functions, and do I have to include
> > App::import('Sanitize'); to make it work (i.e. it's automatic once
> > it's included)?
>
> > Thanks!

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

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

Custom validation rules and saveAll

hello.

i have 2 models
Article hasMany Component

in my Component model i wrote a custom validation rule that relies on
data from Article model.
how can i get this data?
$this->Article->find doesn't work because that function loads data
from the database.. and i need the going-to-be-saved data array

note: i'm using "validate" => "first" in all my saveAlls

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

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

Cakephp 1.3.3 upgrade to 1.3.4 gives problems

Hi,

I just upgraded to the latest version and my rather complex routing
and plugin settings now fail.

I have an 'admin' plugin and i use a 'admin' prefix. The admin plugin
uses a nice admin layout and fills it with actions from the main App
controllers.

Example:
/admin/projects/ -> leads to controller projects and its method
admin_index (which by the way is a scaffold)
within the admin layout from the plugin's /views/layouts folder.

Since the upgrade i get the error:

Missing Layout

Error: The layout file C:\wamp\www\cake_cms\views\layouts\admin.ctp
can not be found or does not exist.

Error: Confirm you have created the file: C:\wamp\www\cake_cms\views
\layouts\admin.ctp

Notice: If you want to customize this error message, create cake_cms
\views\errors\missing_layout.ctp

Seems like the plugin is not used.

Has anyone got an idea where is should start looking?


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

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

Facebook & Session Component

Hi! I'm making a FB Connect site. I have a multi-friend selector. When i send invitations, the user is sent to root. Root is albums/index (because there are picture cards albums). Because the application could have only one album, when I just have one album I sent the user straight to that album.

So I have:


    function index() {
        $albums = $this->Album->find('all');

        //If there's only 1 album, we go straight to the album!
        if (count($albums) == 1) {
            $this->choose($albums[0]['Album']['id']);
        }
    }

    function choose($aid) {
        $album = $this->Album->findByIdAndApplicationId($aid,Configure::read('Application.id'));

        if (empty($album)) {
            throw new Exception("Invalid album id");
            //$this->getBack("Invalid album");
        }

        $this->Session->write('Auth.User.album_id', $aid);
        $this->Session->write('Auth.User.album_name',$album['Album']['name']);
        $this->redirect('/albums/view');
    }

function view($page = 1) {
        $uid = $this->Auth->user('user_id');
        $this->loadModel('User');
        $user = $this->User->find('first', array(
            'contain'=>array(
                'Card'
            ),
            'conditions'=>array('User.id'=>$uid)
        ));
        $cardsPerPage = Configure::read('Album.CardsPerPage');
        $offset = ($page-1) * $cardsPerPage;
        if (!$this->Session->check('Auth.User.album_id')) {

//HERE IS THE PROBLEM

                    $this->Session->setFlash("Choose an album");
                    $this->redirect('/albums/');
        }

The problem is that for some reason, this

    $this->Session->write('Auth.User.album_id', $aid);
        $this->Session->write('Auth.User.album_name',$album['Album']['name']);

is lost when I redirect to albums/view, then this code is executed:

   $this->Session->setFlash("Choose an album");
                    $this->redirect('/albums/');

And I have an infinite loop.

Why this could happen? All other Session variables are ok when I do a debug. Only that variables are lost.

This problem appears ONLY when I come from a Facebook callback (like after sending invitations, or clicking in a Facebook link). When I go to /albums/index by myself I am well redirected to albums/view with the only album selected.

I think may have to do with the fact I'm using Auth.User session space to store other fields.... but it's strange it only happens with Facebook.

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
 
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

Re: beforeCreate() and afterCreate(): better implementation than mine?

Thanks! This makes the code much cleaner.

On Thu, Sep 30, 2010 at 4:39 PM, euromark <dereuromark@googlemail.com> wrote:
> afterSave already contains "created/updated":
> http://book.cakephp.org/view/684/afterSave
> note the param passed
>
> On 30 Sep., 16:35, psybear83 <psybea...@gmail.com> wrote:
>> Hello folks
>>
>> From Ruby On Rails I know the beforeCreate() and afterCreate() hooks
>> of models. I didn't find them for CakePHP, so I implemented them
>> myself:
>>
>>   function isNewRecord() {
>>     return empty($this->id) || $this->field('created') == $this->field('modified');
>>
>>   }
>>
>>   function beforeSave() {
>>     if($this->isNewRecord()) {
>>       return $this->beforeCreate();
>>     }
>>   }
>>
>>   function afterSave() {
>>     if($this->isNewRecord()) {
>>       return $this->afterCreate();
>>     }
>>   }
>>
>>   function beforeCreate() {
>>     return true;
>>   }
>>
>>   function afterCreate() {
>>     return true;
>>   }
>>
>> Sadly, this implementation depends on created and modified fields, and
>> the isNewRecord() method itself isn't very beautiful, too. So maybe
>> there is a better implementation?
>>
>> Thanks
>> Josh
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
>

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

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

phpreports

Does anybody know or make phpreports with CAKEPHP VERSION 1.3

This is a website of how to make phpreports, just php without CAKEPHP

http://phpreports.sourceforge.net/better.html

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

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

Re: beforeCreate() and afterCreate(): better implementation than mine?

afterSave already contains "created/updated":
http://book.cakephp.org/view/684/afterSave
note the param passed

On 30 Sep., 16:35, psybear83 <psybea...@gmail.com> wrote:
> Hello folks
>
> From Ruby On Rails I know the beforeCreate() and afterCreate() hooks
> of models. I didn't find them for CakePHP, so I implemented them
> myself:
>
>   function isNewRecord() {
>     return empty($this->id) || $this->field('created') == $this->field('modified');
>
>   }
>
>   function beforeSave() {
>     if($this->isNewRecord()) {
>       return $this->beforeCreate();
>     }
>   }
>
>   function afterSave() {
>     if($this->isNewRecord()) {
>       return $this->afterCreate();
>     }
>   }
>
>   function beforeCreate() {
>     return true;
>   }
>
>   function afterCreate() {
>     return true;
>   }
>
> Sadly, this implementation depends on created and modified fields, and
> the isNewRecord() method itself isn't very beautiful, too. So maybe
> there is a better implementation?
>
> Thanks
> Josh

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

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

beforeCreate() and afterCreate(): better implementation than mine?

Hello folks

From Ruby On Rails I know the beforeCreate() and afterCreate() hooks
of models. I didn't find them for CakePHP, so I implemented them
myself:

function isNewRecord() {
return empty($this->id) || $this->field('created') == $this-
>field('modified');
}

function beforeSave() {
if($this->isNewRecord()) {
return $this->beforeCreate();
}
}

function afterSave() {
if($this->isNewRecord()) {
return $this->afterCreate();
}
}

function beforeCreate() {
return true;
}

function afterCreate() {
return true;
}

Sadly, this implementation depends on created and modified fields, and
the isNewRecord() method itself isn't very beautiful, too. So maybe
there is a better implementation?

Thanks
Josh

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

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

Re: opening a popup window when clicking on a link

thx mike,

i was hoping there is a way with $ajax->link and scriptaculous or sth
like that......u know using the ajax helper

On 30 Sep., 15:52, "Mike Karthauser" <mi...@brightstorm.co.uk> wrote:
> On Thu, September 30, 2010 2:03 pm, Tomfox Wiranata wrote:
> > hi everyone,
>
> > in my view I have  a link:
> >                               echo $html->link('My
> > Favorites'...........);
>
> > now when a user clicks the link i want a popup window to open and show
> > data from the database with the ajax paginator. but how can i open a
> > new window as a popup??
>
> doing this will require client side js.
>
> you could look at jquery ui modalhttp://jqueryui.com/demos/dialog/#modal-message
>
> bear in mind there are users that cant launch new windows or modal boxes
> (mobile users for example) so provide an inpage way to do it and then
> enhance with javascript accordingly.
>
> --
> Mike Karthauser
> Managing Director - Brightstorm Ltd
>
> Email: mi...@brightstorm.co.uk
> Web:http://www.brightstorm.co.uk
> Tel:  07939 252144begin_of_the_skype_highlighting              07939 252144      end_of_the_skype_highlighting(mobile)
> Fax: 0870 1320560
>
> Address: 1 Brewery Court, North Street, Bristol, BS3 1JS

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

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

Re: CakePHP ignores notEmpty validation rule when the field's name is not a key in $data! (Bug or Feature?)

So rapid development sounds to me like developing without testing...
Not very promising. And it would be *much* more rapid when such basic
stuff was already taken care of, because every serious web app will
have to implement this.

On Thu, Sep 30, 2010 at 3:34 PM, euromark <dereuromark@googlemail.com> wrote:
> well, it is this way for "rapid development"
> not for "most secure web application" :)
>
> the second part is your job then
> although i think my methods should find their way into the core
> because they certainly help to achieve that.
>
>
> On 30 Sep., 15:28, Joshua Muheim <psybea...@gmail.com> wrote:
>> Thanks Euromark for your good hint. I certainly should read through
>> your blogs in the near future...
>>
>> But do you know why CakePHP handles stuff this way? Looks very, very
>> unintuitive to me. With Ruby on Rails I had much better experiences
>> about stuff like this a few years ago (everything just seemed to work
>> the way I expected it although I didn't have much experience with it
>> then), and I'm sure today they even have progressed much farer...
>>
>> It seems a bit sad to me that CakePHP clearly doesn't seem to be able
>> to come even close to the experience of RoR. Any yes, I know CakePHP
>> isn't RoR, and yes, I could switch (well actually, I can't)... Just my
>> 2 c€nts...
>>
>>
>>
>> On Thu, Sep 30, 2010 at 2:58 PM, euromark <dereurom...@googlemail.com> wrote:
>> > actually it is NOT a bug
>> > although many are not aware of that behavior :)
>>
>> > you need to make sure that the field is passed to the validation
>> > otherwise it will be ignored
>>
>> > @seehttp://www.dereuromark.de/2010/09/21/saving-model-data-and-security/
>>
>> > On 30 Sep., 14:52, psybear83 <psybea...@gmail.com> wrote:
>> >> Hi everybody
>>
>> >> I have baked the following very straight-forward model:
>>
>> >> class Post extends AppModel {
>> >>         var $name = 'Post';
>> >>         var $displayField = 'name';
>> >>         var $validate = array(
>> >>                 'name' => array(
>> >>                         'notempty' => array(
>> >>                                 'rule' => array('notempty')
>> >>                         ),
>> >>                 ),
>> >>         );
>>
>> >> }
>>
>> >> It only needs a value for "name" to be saved.
>>
>> >> Now I've written the following 3 tests:
>>
>> >>   function testShouldNotBeValidWithEmptyName() {
>> >>     $this->Post->create(array('name' => ''));
>> >>     $this->assertFalse($this->Post->validates());
>> >>   }
>>
>> >>   function testShouldNotBeValidWithoutName() {
>> >>     $this->Post->create();
>> >>     $this->assertFalse($this->Post->validates()); // Fails!
>> >>   }
>>
>> >>   function testShouldNotBeValidWithNullName() {
>> >>     $this->Post->create(array('name' => null));
>> >>     $this->assertFalse($this->Post->validates());
>> >>   }
>>
>> >> I expect all three of them to work, but the 2nd one fails! So why does
>> >> it validate when there truly is no value for the "name" field? Is this
>> >> really the way it should be, or is it a bug?
>>
>> >> I'm on version 1.3.4.
>>
>> >> Thanks for help
>> >> Josh
>>
>> > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with their CakePHP related questions.
>>
>> > You received this message because you are subscribed to the Google Groups "CakePHP" group.
>> > To post to this group, send email to cake-php@googlegroups.com
>> > To unsubscribe from this group, send email to
>> > cake-php+unsubscribe@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php?hl=en
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
>

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

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

Re: opening a popup window when clicking on a link

On Thu, September 30, 2010 2:03 pm, Tomfox Wiranata wrote:
> hi everyone,
>
> in my view I have a link:
> echo $html->link('My
> Favorites'...........);
>
>
> now when a user clicks the link i want a popup window to open and show
> data from the database with the ajax paginator. but how can i open a
> new window as a popup??

doing this will require client side js.

you could look at jquery ui modal
http://jqueryui.com/demos/dialog/#modal-message

bear in mind there are users that cant launch new windows or modal boxes
(mobile users for example) so provide an inpage way to do it and then
enhance with javascript accordingly.

--
Mike Karthauser
Managing Director - Brightstorm Ltd

Email: mikek@brightstorm.co.uk
Web: http://www.brightstorm.co.uk
Tel: 07939 252144 (mobile)
Fax: 0870 1320560

Address: 1 Brewery Court, North Street, Bristol, BS3 1JS

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

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

Re: CakePHP ignores notEmpty validation rule when the field's name is not a key in $data! (Bug or Feature?)

well, it is this way for "rapid development"
not for "most secure web application" :)

the second part is your job then
although i think my methods should find their way into the core
because they certainly help to achieve that.


On 30 Sep., 15:28, Joshua Muheim <psybea...@gmail.com> wrote:
> Thanks Euromark for your good hint. I certainly should read through
> your blogs in the near future...
>
> But do you know why CakePHP handles stuff this way? Looks very, very
> unintuitive to me. With Ruby on Rails I had much better experiences
> about stuff like this a few years ago (everything just seemed to work
> the way I expected it although I didn't have much experience with it
> then), and I'm sure today they even have progressed much farer...
>
> It seems a bit sad to me that CakePHP clearly doesn't seem to be able
> to come even close to the experience of RoR. Any yes, I know CakePHP
> isn't RoR, and yes, I could switch (well actually, I can't)... Just my
> 2 c€nts...
>
>
>
> On Thu, Sep 30, 2010 at 2:58 PM, euromark <dereurom...@googlemail.com> wrote:
> > actually it is NOT a bug
> > although many are not aware of that behavior :)
>
> > you need to make sure that the field is passed to the validation
> > otherwise it will be ignored
>
> > @seehttp://www.dereuromark.de/2010/09/21/saving-model-data-and-security/
>
> > On 30 Sep., 14:52, psybear83 <psybea...@gmail.com> wrote:
> >> Hi everybody
>
> >> I have baked the following very straight-forward model:
>
> >> class Post extends AppModel {
> >>         var $name = 'Post';
> >>         var $displayField = 'name';
> >>         var $validate = array(
> >>                 'name' => array(
> >>                         'notempty' => array(
> >>                                 'rule' => array('notempty')
> >>                         ),
> >>                 ),
> >>         );
>
> >> }
>
> >> It only needs a value for "name" to be saved.
>
> >> Now I've written the following 3 tests:
>
> >>   function testShouldNotBeValidWithEmptyName() {
> >>     $this->Post->create(array('name' => ''));
> >>     $this->assertFalse($this->Post->validates());
> >>   }
>
> >>   function testShouldNotBeValidWithoutName() {
> >>     $this->Post->create();
> >>     $this->assertFalse($this->Post->validates()); // Fails!
> >>   }
>
> >>   function testShouldNotBeValidWithNullName() {
> >>     $this->Post->create(array('name' => null));
> >>     $this->assertFalse($this->Post->validates());
> >>   }
>
> >> I expect all three of them to work, but the 2nd one fails! So why does
> >> it validate when there truly is no value for the "name" field? Is this
> >> really the way it should be, or is it a bug?
>
> >> I'm on version 1.3.4.
>
> >> Thanks for help
> >> Josh
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with their CakePHP related questions.
>
> > You received this message because you are subscribed to the Google Groups "CakePHP" group.
> > To post to this group, send email to cake-php@googlegroups.com
> > To unsubscribe from this group, send email to
> > cake-php+unsubscribe@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php?hl=en

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

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