Links to previous forum messages

2011-02-24 Thread Jeremy Burns
Slightly off topic, but relevant. I have noticed lately that links such as 
this one:

http://groups.google.com/group/cake-php/msg/022622017dd329f8

...which ought to take me to a forum post are just taking me to the Google 
Groups index page. The id of the post does not seem to tie up to a post 
either. I'm aware that Google Groups changed a few months back; am I missing 
something? Is there a way to go to this previous post?

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Auto Increment A Field

2011-02-24 Thread Ryan Schmidt
On Feb 25, 2011, at 01:16, Robert J. Maiolo wrote:
> On Thu, Feb 24, 2011 at 11:09 PM, tubiz wrote:
>> Please I would like to know how to auto increment a field in a table
>> in my database. I want to to be incremented once the action is clicked
>> upon.
> 
> why not just retrieve the value, increment then update the field?

Because that's not atomic. (Between the time you retrieve the value and the 
time you set the new value, another query may have changed the value already.)

Instead, you want to have the equivalent of the SQL...

UPDATE table SET field=field+1 WHERE somecondition;

...where it all occurs in a single query.

How to do this in CakePHP was recently asked in this group; here's one reply 
from that thread that shows one possible solution:

http://groups.google.com/group/cake-php/msg/022622017dd329f8




-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: cakephp out side root folder

2011-02-24 Thread Jeremy Burns | Class Outfit
http://book.cakephp.org/#!/view/915/Advanced-Installation

Jeremy Burns
Class Outfit

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

On 24 Feb 2011, at 18:30, danieln wrote:

> Hi,
> 
> Is it possible that I put my entire cakephp folder out side the root
> folder and just use a php file in the public_html folder to point to
> it?
> 
> will cakephp still run in this way?
> 
> -- 
> Our newest site for the community: CakePHP Video Tutorials 
> http://tv.cakephp.org 
> Check out the new CakePHP Questions site http://ask.cakephp.org and help 
> others with their CakePHP related questions.
> 
> 
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Search function

2011-02-24 Thread MeatSandwich
Hi all,

I'm new to cakephp and only know a bit of php so I'm on a steep
learning curve since although I've made websites using php and mysql
before they were all a bit simple. I'm not looking for code here but
some pointers for me so I know what to learn.

The app I'm making will end up with lots of members and I'd like to
make a search function so people can find other people easily. I've
discovered searchable-behaviour-for-cakephp and hopefully that'll
provide most of what I want but as another way to search rather than a
text box, I'd also like to have the letters of the alphabet so a user
can click and go straight to that letter.

As well as that, members will say in their profiles what their
favourite animals are, ie cats/dogs/horses etc - they'll have 20 to
choose from. I'd like my search function to have checkboxes
representing each animal and someone who was searching could check the
dogs box and only people who like dogs will be listed, they could then
also check cats box and the members who like dogs and cats will be
shown. If possible I'd like the list to update automatically as each
box is clicked.

I have everything else set up and only need help with this search
part. Assuming searchable-behaviour-for-cakephp does me for my text
search box, I reckon the alphabet thing will be something like making
a link for each letter and somehow making that link run a query,
hopefully that will work.

But the checkbox thing that updates automatically I'm not sure about.
Is it ajax I need? Are there any particular methods I should be using?

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


cakephp out side root folder

2011-02-24 Thread danieln
Hi,

Is it possible that I put my entire cakephp folder out side the root
folder and just use a php file in the public_html folder to point to
it?

will cakephp still run in this way?

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Auto Increment A Field

2011-02-24 Thread Robert J. Maiolo
why not just retrieve the value, increment then update the field?

On Thu, Feb 24, 2011 at 11:09 PM, tubiz  wrote:

> Please I would like to know how to auto increment a field in a table
> in my database. I want to to be incremented once the action is clicked
> upon.
> Thanks.
>
> --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group
> at http://groups.google.com/group/cake-php
>

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Auto Increment A Field

2011-02-24 Thread tubiz
Please I would like to know how to auto increment a field in a table
in my database. I want to to be incremented once the action is clicked
upon.
Thanks.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: date time calendar picker

2011-02-24 Thread Tapan Kumar Thapa
Hello Community,

I finally managed to achieve what i was wanting with calendar.

Good calendar with date,time and seconds. (
http://www.rainforestnet.com/datetimepicker-tutorial.htm)

My code to use above calender in $this->Form->input is:

Html->script('datetimepicker_css'); //(Actual
datetimepicker_css.js i have put under
C:\Projects\cakephp-1.3.7-0-g9f58309\app\webroot\js\datetimepicker_css.js)
?>
Session->read('Auth.User.first_name') . '.'; ?>Html->link('Logout', array('controller' =>
'users', 'action' => 'logout')); ?>
Reports
Form->create(array('controller' => 'users', 'action' =>
'view'));
echo $form->input('StartDate',array('label'=>'StartDate','type'=>'text',
'onclick'=>"javascript:NewCssCal
('IncomingStartDate','MMdd','arrow',true,'24',true)"));
echo $form->input('EndDate',array('label'=>'EndDate','type'=>'text',
'onclick'=>"javascript:NewCssCal
('IncomingEndDate','MMdd','arrow',true,'24',true)"));
echo $this->Form->end('Search');
?>

Thanks all for your input and this is for some else as well if they want to
achieve the same.

Regards
Tapan Thapa
India

On Wed, Feb 23, 2011 at 9:02 PM, Tapan Kumar Thapa <
tapan.th...@hindustantimes.com> wrote:

> No i am sorry but i don't want to use ajax at all as i don't have much
> knowledge on this.
>
> I just to enable start and end date search via a calendar which should have
> date and time with seconds feature so i have found out jquery calendar (
> http://jqueryui.com/demos/). I want to implement this with cake form
> helper (or with any other method). Please suggest.
>
> Regards
> Tapan Thapa
> India
>
>
> On Wed, Feb 23, 2011 at 5:12 PM, Deividas J  wrote:
>
>> if I understand you well you want to call action with .ajax. I do like
>> this:
>>
>> echo $this->Form->create(null, array(
>> 'default' => false,
>>  'inputDefaults' => array(
>> 'label' => false,
>> 'div' => false
>>  )
>> ));
>>
>> //Input-
>>
>> echo $this->Form->input('StartDate', array(
>>  'type' => 'datetime',
>> 'dateFormat' => 'DMY',
>> 'minYear' => date('Y'),
>> 'maxYear' => date('Y'),
>>
>> 'timeFormat' => '24',
>> 'selected' => date('Y-m-d 0:00:s'),
>> 'attributes' => array(),
>> 'empty' => FALSE
>> )
>> );
>> echo $this->Form->input('EndDate', array(
>>
>> 'type' => 'datetime',
>> 'dateFormat' => 'DMY',
>> 'minYear' => date('Y'),
>> 'maxYear' => date('Y'),
>> 'timeFormat' => '24',
>>
>> //'selected' => null,
>> 'selected' => date('Y-m-d H:i:s'),
>> 'attributes' => array(),
>> 'empty' => FALSE
>> )
>> );
>>
>> //--
>>
>> echo $this->Form->end(array(
>> 'label' => 'Search',
>> 'id' => 'seach'
>> ));
>>
>> $this->Js->get('#seach')->event('click',
>> $this->Js->request(
>> array(
>>  'controller' => 'users',
>> 'action' => 'view',
>>  ),
>> array(
>> 'async' => true,
>>  'dataExpression' => true,
>> 'type' => 'json',
>>  'method' => 'post',
>> 'data' => $js->serializeForm(array('isForm' => false, 'inline' => true)),
>>  'success' => 'renderTrack(data);',
>> )
>> ));
>>
>> I hope you looking  for this.
>>
>>
>>
>>
>> On Wed, Feb 23, 2011 at 1:33 PM, Tapan Kumar Thapa <
>> tapan.th...@hindustantimes.com> wrote:
>>
>>> Hello Community,
>>>
>>> Finally i have got one jquery based calendar.
>>>
>>> http://jqueryui.com/docs/Getting_Started
>>>
>>> how to from this site:
>>>
>>> 
>>>
>>> *JS:*
>>>
>>> $('#date').datepicker();
>>>
>>> My current code to select date with form helper is:
>>>
>>> echo $this->Form->create(array('controller' => 'users', 'action' => 
>>> 'view'));
>>>
>>>
>>>
>>> echo $this->Form->input('StartDate', array(
>>> 'type' => 'datetime',
>>> 'dateFormat' => 'DMY',
>>> 'minYear' => date('Y'),
>>> 'maxYear' => date('Y'),
>>>
>>>
>>>
>>> 'timeFormat' => '24',
>>> 'selected' => date('Y-m-d 0:00:s'),
>>> 'attributes' => array(),
>>> 'empty' => FALSE
>>> )
>>> );
>>> echo $this->Form->input('EndDate', array(
>>>
>>>
>>>
>>> 'type' => 'datetime',
>>> 'dateFormat' => 'DMY',
>>> 'minYear' => date('Y'),
>>> 'maxYear' => date('Y'),
>>> 'timeFormat' => '24',
>>>
>>>
>>>
>>> //'selected' => null,
>>> 'selected' => date('Y-m-d H:i:s'),
>>> 'attributes' => array(),
>>> 'empty' => FALSE
>>> )
>>> );
>>> echo $this->Form->end('Search');
>>>
>>>
>>>
>>>
>>> Can anyone suggest how to use jave script calendar under form-create-input?
>>>
>>> Please suggest.
>>>
>>> Regards
>>> Tapan Thapa
>>> India
>>>
>>>
>>>
>>> On Tue, Feb 22, 2011 at 12:46 PM, andy_the ultimate baker <
>>> anandghaywankar...@gmail.com> wrote:
>>>
 u cant expect all that u need will get exactly.
 u need to change the format in its code.
 have u tried the options at the right side of page ?
 and bellow it the possible changes and functions are given just refer
 them.

 Anand
 cake developer
 www.anshusys.com.

 On Feb 22, 12:01 pm, Tapan Kumar Thapa
  wrote:
 > 

Re: Help - HABTM Multi-Select Field

2011-02-24 Thread cricket
On Thu, Feb 24, 2011 at 9:36 AM, Mr.Jayesh  wrote:
> Hi everyone,
>
> I am working on a project where I have set up a habtm for Categories.
> I am using CakePHP 1.3
> The issue I am stuck is as under:
>
> I have a post form, where I have a Milti Select box for categories, so
> I can select all the categories that the post belongs to and post it.
> It works fine and all the relevant entries goes to the correct tables
> (posts, categories, categories_posts).
>
> I am using Tree structure, so I have lft and rght set in the
> categories table.
>
> I have two types forms field in different forms which is to be
> populated by $categories:
> 1. Dropdown - for creating new categories in system.
> 2. Multi-Select - for posts
>
> and code of $controllers that I used is:
>
> Dropdown: $this->Category->generatetreelist (null, '{n}.Category.id',
> '{n}.Category.cat_name', '...');
> This works fine and list is seem to be in hierarchy
>
> But problem is when I use similar code of Posts form, the category
> list is just in plain list without hierarchy. Code used for that is:
>
> $categories = $this->Post->Category->generatetreelist (null,
> '{n}.Category.id', '{n}.Category.cat_name', '...');
>
> And in view:
> echo $this->Form->input('Category.Category', array('label' =>
> 'Categories:', 'options' => $categories));
>
> I want to get an hierarchical list of categories in the multi-select
> field as set up in database. I tried many ways but no result.
> Please advice.

Instead of calling generatetreelist() directly, you could call a
custom method in Category  model (which would call it). Then loop
through the data adding $depth * $n NBSPs before each nested
title/name, where $n is, eg. 2.

er ... wait a sec. I just remembered that the method already does this for you:

http://api.cakephp.org/class/tree-behavior#method-TreeBehaviorgeneratetreelist

Note the spacer param. Make that '  ' and you're golden.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Easiest way to get data from a model (better way than $model->data['modelname']['field'])?

2011-02-24 Thread LunarDraco
Great, so now when I need to build my view that displays data from
four different models, I can call set a bunch of times in the
controller for each model. come up with a whole new form helper to
deal with data that does not have a model key. And deal with duplicate
fields labeled 'id' in my html form. Then when I post my data from a
form back to the controller I can put a bunch more code in place to
remap all the view data and try to figure out what fields belong to
which models so I can save them correctly.

Or I could use this new convention in the models only (which would be
ok) and then the cake array convention in the views so I can
constantly second guess what format of data i'm working with.

Sarcasm was intended.

Seriously now. Once you get past the simple one model form app and
really start to use cake, your going to find your new simplified
function is going to get in your way or its going to be used so little
you will question why you still have it. There are many reasons the
cake data arrays are created the way they are. And its NOT because
thats the way its always been, or some ridged developer wouldn't
change. Its because it makes for very consistent and portable data
from the Model to the Controller to the View and back. Its not just
data its also a consistent structured container for the data so all
the cake 'magic' from the model, controller and view can make use of
it.

If you find you really just need a single field for a specific record
you can call the model::field() function which will go all the way to
the db to get the data. (slower but more precise in a few situations)
as in:
echo $this->Post->field('name');

I give you credit on at least one point. You put the code in the model
instead of the controller. So your a bit ahead of a lot of the new
developers to a MVC framework. ;)

One point you didn't mention is multiple records from the likes of
find('all') or find('list'). Or dealing with data that is many models
deep (recursive).

There are many, many, many reasons to use the cake array structure.
I would encourage you to re-read chapter 3.7.3

I assumed quite a bit about your project/problem as you never stated
you had one other than the new shoes feel different than the old ones
your used to wearing. Try them out for a week or so, maybe its just
the change you needed.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: any way to omit app/webroot when request image file or directory inside it

2011-02-24 Thread cricket
On Thu, Feb 24, 2011 at 11:08 PM, Ryan Schmidt
 wrote:
> On Feb 24, 2011, at 11:52, mohammad Al-Ani wrote:
>
>> when I request any file or directory that settle inside webroot directory. 
>> The URL automatically show the app/wedroot slug
>>
>> ex:
>>
>> request
>>
>>     www.mydomian.com/css/main.css
>>
>> change in browser to
>>
>>     www.mydomian.com/app/webroot/css/main.css
>
> webroot is supposed to be the directory your Apache DocumentRoot directive 
> points at; you clearly haven't done this.

Not necessarily. For those who can't change DocumentRoot, there are
the various .htaccess files with rewrite rules to handle that. If
that's the case, DocumentRoot doesn't change, from Apache's
perpective.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: afterDelete not running as intended

2011-02-24 Thread adam_g2000
Hi Krissy,

Thanks for resolving my problem, you are a star.

I noticed somehow when I baked the project there were duplicate
models, two files for each one image.php and one images.php and I
guess in a daze I'd added this to the wrong one.

I've learnt a valuable lesson and am very grateful.

Adam.

On Feb 25, 9:35 am, "Krissy Masters" 
wrote:
>  class Image extends AppModel {
>
> not "images" models are singular
>
> afterDelete is in Image Model so no need $images = $this->Image->find('all',
> $conditions);
>
> change to:
>
> $images = $this->find('all', $conditions);
>
> K
>
>
>
> -Original Message-
> From: cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] On Behalf
>
> Of adam_g2000
> Sent: Thursday, February 24, 2011 4:36 PM
> To: CakePHP
> Subject: Re: afterDelete not running as intended
>
> Hi again Jeremy!
>
> Thanks for that, there's my sanity check! I've done that, it's now
> sitting in my Images Model. Unfortunately, nothing happens still
>
> Here's the entire model, am I still doing something stupid?
>
>  class images extends AppModel {
>         var $name = 'images';
>         var $validate = array(
>                 'filename' => array(
>                         'notempty' => array(
>                                 'rule' => array('notempty')
>                         ),
>                 ),
>         );
>
>         function afterDelete() {
>                 // Re-sort orders to remove the 'hole'
>                 // Create an array of the image table contents of IDs and
> Orders.
>                 $conditions = array(
>                                                 'fields' =>
> array('id','order'),
>                                                 'order' => 'Image.order ASC'
>                 );
>                 $images = $this->Image->find('all', $conditions);
>                 //Loop through looking for order/count disparity and tidying
> up when
> disparity is found.
>                 $counter = 1;
>                 foreach ($images as $image):
>                         $image['Image']['order'] = $counter;
>                         $this->Image->save($image, false,
> array('id','order'));
>                         $counter++;
>                 endforeach;
>         }
> }
> ?>
>
> On Feb 24, 7:22 pm, Jeremy Burns | Class Outfit
>  wrote:
> > Is this in a model or a controller? I am guessing it's in a controller
> because you have a redirect statement. To make it run as afterDelete you
> need to move it into the model (afterDelete is a model callback) and then
> you'd need to remove the redirect statement because it will error.
>
> > Jeremy Burns
> > Class Outfit
>
> > jeremybu...@classoutfit.comhttp://www.classoutfit.com
>
> > On 24 Feb 2011, at 03:36, adam_g2000 wrote:
>
> > > Hi Guys,
>
> > > I have this method I've written...
>
> > > function tidyup() {
> > >    //Re-sort orders to remove the 'hole'
> > >    // Create an array of the image table contents of IDs and Orders.
> > >    $conditions = array(
> > >                                    'fields' => array('id','order'),
> > >                                    'order' => 'Image.order ASC'
> > >    );
> > >    $images = $this->Image->find('all', $conditions);
> > >    //Loop through looking for order/count disparity and tidying up when
> > > disparity is found.
> > >    $counter = 1;
> > >    foreach ($images as $image):
> > >            if ($image['Image']['order'] != $counter) {
> > >                    $image['Image']['order'] = $counter;
> > >                    $this->Image->save($image, false,
> array('id','order'));
> > >            }
> > >            $counter++;
> > >    endforeach;
> > >    $this->redirect(array('action' => 'index'));
> > > }
>
> > > ...to reorder a list of Images in a database table once one is
> > > deleted. This works perfectly.
>
> > > However, what I really want to do is have it triggered automatically
> > > once an Image is deleted.
>
> > > So I would expect just changing function tidyup to function
> > > afterDelete should work perfectly. When I do that, the function never
> > > runs.
>
> > > Can I get a sanity check please? Can anyone spot my error?
>
> > > Thanks in advance for any offers of assistance.
>
> > > --
> > > Our newest site for the community: CakePHP Video
> Tutorialshttp://tv.cakephp.org
> > > Check out the new CakePHP Questions sitehttp://ask.cakephp.organdhelp
> others with their CakePHP related questions.
>
> > > To unsubscribe from this group, send email to
> > > cake-php+unsubscr...@googlegroups.com For more options, visit this group
> athttp://groups.google.com/group/cake-php
>
> --
> Our newest site for the community: CakePHP Video 
> Tutorialshttp://tv.cakephp.org
> Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help
> others with their CakePHP related questions.
>
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group 
> athttp://groups.google.com/group/cake-php

RE: requestAction question

2011-02-24 Thread Krissy Masters
Not sure I follow you there. The element on the side only gets refreshed if 
loaded thru standard HTTP request.

Page A, B and C are different controller actions unrelated to each other so to 
get that data for each page if loaded thru HTTP will require getting unrelated 
models data if done thru the controllers action. No? Maybe not following you 
there...sorry if I'm wrong.

K

-Original Message-
From: cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] On Behalf Of 
Dr. Loboto
Sent: Friday, February 25, 2011 12:40 AM
To: CakePHP
Subject: Re: requestAction question

Based on your description I do not see need in requestAction at all.
If all you need is 1 model call and one element output you can add
data call to appropriate actions or beforeFilter/beforeRender and add
element output to the view/layout. Just one more line of code in
comparison with requestAction.

On 25 фев, 06:21, "Krissy Masters"  wrote:
> Maybe I read it wrong back in the day but something idles in my head about
> requestAction being bad. Is this true or still in effect? I am using 1.3.7
> and I think I remember reading back in 1.2 its better to not use that
> function.
>
> “If used without caching requestAction can lead to poor performance. It is
> rarely appropriate to use in a controller or model.”
>
> I have 1 element on 3 pages where I simply need to grab 4 fields from a db
> for the element. The element is loaded originally on the first page left
> side navigation column, and links load content into the main column so the
> element is never refreshed since its on the side nav column except if
> someone “open in new tab / window” on the link so the element has no data
> because its originally loaded on the main page. So rather than build that
> data call into each of those 3 pages I figured request would be the best
> option.
>
> My Picasso below :)
>
> Side Col  |   Main Col
> ___
> | nav => loads into main  |   content gets loaded here via ajax
> |--|
> |
> | element |
> |
> 
>
> Just looking for some input on the matter.
>
> Thanks,
>
> K

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: requestAction question

2011-02-24 Thread Dr. Loboto
Based on your description I do not see need in requestAction at all.
If all you need is 1 model call and one element output you can add
data call to appropriate actions or beforeFilter/beforeRender and add
element output to the view/layout. Just one more line of code in
comparison with requestAction.

On 25 фев, 06:21, "Krissy Masters"  wrote:
> Maybe I read it wrong back in the day but something idles in my head about
> requestAction being bad. Is this true or still in effect? I am using 1.3.7
> and I think I remember reading back in 1.2 its better to not use that
> function.
>
> “If used without caching requestAction can lead to poor performance. It is
> rarely appropriate to use in a controller or model.”
>
> I have 1 element on 3 pages where I simply need to grab 4 fields from a db
> for the element. The element is loaded originally on the first page left
> side navigation column, and links load content into the main column so the
> element is never refreshed since its on the side nav column except if
> someone “open in new tab / window” on the link so the element has no data
> because its originally loaded on the main page. So rather than build that
> data call into each of those 3 pages I figured request would be the best
> option.
>
> My Picasso below :)
>
> Side Col                  |       Main Col
> ___
> | nav => loads into main  |   content gets loaded here via ajax
> |--|
> |
> | element                 |
> |
> 
>
> Just looking for some input on the matter.
>
> Thanks,
>
> K

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: any way to omit app/webroot when request image file or directory inside it

2011-02-24 Thread Ryan Schmidt
On Feb 24, 2011, at 11:52, mohammad Al-Ani wrote:

> when I request any file or directory that settle inside webroot directory. 
> The URL automatically show the app/wedroot slug
> 
> ex:
> 
> request 
> 
> www.mydomian.com/css/main.css
> 
> change in browser to 
> 
> www.mydomian.com/app/webroot/css/main.css

webroot is supposed to be the directory your Apache DocumentRoot directive 
points at; you clearly haven't done this.


-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Model data appears to unset after save, is this correct?

2011-02-24 Thread Greg Skerman
Thanks Cricket,

I realise a lot of the stuff i'm doing in the model would be better served
in a component - maybe one day if i revisit it i'll break it out properly
into a component... for the time being it "works", and its not "wrong" ...
maybe just not as "right" as it could be :P




On Fri, Feb 25, 2011 at 5:43 AM, cricket  wrote:

> On Thu, Feb 24, 2011 at 3:43 AM, Greg Skerman  wrote:
> > Hi,
> >
> > I've been working on a very simple app to upload and resize some images,
> and
> > name the file in accordance with some information that has been provided
> in
> > a form.
> >
> > To do this, my model has a public method "createFilename", which relies
> on
> > $this->data to build the filename in accordance with the provided
> business
> > rules.
> >
> > It was all working fine, until I connected the model to a database table
> and
> > started also saving the meta-data now it appears $this->data is being
> > unset for subsequent calls to the method.
> >
> > The method is simple enough:
> >
> > public function createFilename() {
> >
> > CakeLog::write('debug', 'photo name is '.
> > $this->data['Photo']['name']);
> >
> > $name = $this->data['Photo']['name'];
> >
> > $level = $this->data['Photo']['level'];
> >
> > $category = $this->data['Photo']['category'];
> >
> > $month = strtoupper($this->data['Photo']['month']);
> >
> >
> > return $level . $category . $month . $name . '.jpg';
> >
> > }
> >
> >
> > According to the information that I log, in the 4 times this method is
> > called during the processing of the image, the first time
> > $this->data['Photo']['name']  contains data, and then each subsequent
> call
> > is empty.
> >
> > The first time the method is called is at validation to prevent duplicate
> > files with the same metadata being created, and this seems to be working
> > fine, but then the following times (which are used for naming the file
> after
> > it has been manipulated, moving the file out of the TMP directory into
> the
> > uploaded images directory, and including the filename in an email
> > attachment, $this->data appears to be empty.
>
> I realise, from your other post, that you're not doing calling that
> method repeatedly anymore. It's really inefficient to do that.
>
> The way I've approached this is to use a FileHandlerComponent and
> ImageHandlerComponent. Any controller that deals with an upload calls
> __handleUpload() after saving the record. The first component deals
> with moving the file to the correct location and the second with
> resizing. I split them into separate components because I deal with a
> lot of non-image uploads.
>
> Example from FilesController:
>
> private function __handleImageUpload()
> {
>$this->FileHandler->setModelName('Link');
>$this->FileHandler->setBase(WWW_ROOT);
>$this->FileHandler->setSubDirectory('files/links');
>
>if ($this->FileHandler->upload('upload', false))
>{
>$upload_data = $this->FileHandler->getUploadData();
>
>/* create a reasonably-sized image
> */
>if (!empty($upload_data))
>{
>/* resize if necessary
> */
>$img_data = $this->ImageHandler->apply(
>array_merge($this->Link->image_settings,
> array('basename' =>
> $upload_data['basename'])),
>
>  
> $this->FileHandler->getBase().$upload_data['directory'].DS.$upload_data['basename'],
>
>  $upload_data['directory'].DS.$upload_data[0]['basename']
>);
>
>/* Save image details
> */
>if (is_array($img_data) && !empty($img_data))
>{
>$data = array(
>'Link' => array(
>'id' => $this->Link->id,
>'directory' =>
> $upload_data[0]['directory'],
>'basename' =>
> $img_data['basename'],
>'extension' =>
> $img_data['extension'],
>'type' => $img_data['type'],
>'size' => $img_data['size'],
>'width' =>
> $img_data['width'],
>'height' =>
> $img_data['height']
>)
>);
>
>/* see if there's already an image
> */
>$old_image = $this->Link->find(
>'first',
>array(
>'conditions' =>

RE: requestAction question

2011-02-24 Thread Krissy Masters
Thanks.

I am half way thru deciding. I am building a function just to get those 4
fields and cache the data. requestAction might come next depending on how I
feel. requestAction in my case would only be called if the user wants to
open the page in a new Window why is beyond me but I can not predict the
habits of every user.

Thanks guys.

K

From: cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] On Behalf
Of Larry E. Masters
Sent: Thursday, February 24, 2011 11:42 PM
To: cake-php@googlegroups.com
Subject: Re: requestAction question

When used properly it has it uses. But I did not think people would use it
the way they do when I added it the core.

http://mark-story.com/posts/view/how-using-requestaction-increased-performan
ce-on-my-site


-- 
Larry E. Masters 

On Thu, Feb 24, 2011 at 8:31 PM, Sam Sherlock 
wrote:
Andy Gale mentions that requestAction was not an option for use in a large
scale site (in video on the tv site)

http://mark-story.com/posts/view/reducing-requestaction-use-in-your-cakephp-
sites-with-fat-models

this article by teknoid is about menu specifically - I just found it &
bookmarked it
http://nuts-and-bolts-of-cakephp.com/2008/08/20/dynamic-menus-without-reques
taction-in-cakephp-12/

 - S



On 25 February 2011 00:21, Krissy Masters 
wrote:
Maybe I read it wrong back in the day but something idles in my head about
requestAction being bad. Is this true or still in effect? I am using 1.3.7
and I think I remember reading back in 1.2 its better to not use that
function.

“If used without caching requestAction can lead to poor performance. It is
rarely appropriate to use in a controller or model.”

I have 1 element on 3 pages where I simply need to grab 4 fields from a db
for the element. The element is loaded originally on the first page left
side navigation column, and links load content into the main column so the
element is never refreshed since its on the side nav column except if
someone “open in new tab / window” on the link so the element has no data
because its originally loaded on the main page. So rather than build that
data call into each of those 3 pages I figured request would be the best
option.

My Picasso below :)


Side Col                  |       Main Col
___
| nav => loads into main  |   content gets loaded here via ajax
|--|
|
| element                 |
|




Just looking for some input on the matter.

Thanks,

K

--
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help
others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at
http://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help
others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at
http://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help
others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at
http://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: requestAction question

2011-02-24 Thread Larry E. Masters
When used properly it has it uses. But I did not think people would use it
the way they do when I added it the core.

http://mark-story.com/posts/view/how-using-requestaction-increased-performance-on-my-site


-- 
Larry E. Masters


On Thu, Feb 24, 2011 at 8:31 PM, Sam Sherlock wrote:

> Andy Gale mentions that requestAction was not an option for use in a large
> scale site (in video on the tv site)
>
>
> http://mark-story.com/posts/view/reducing-requestaction-use-in-your-cakephp-sites-with-fat-models
>
> this article by teknoid is about menu specifically - I just found it &
> bookmarked it
>
> http://nuts-and-bolts-of-cakephp.com/2008/08/20/dynamic-menus-without-requestaction-in-cakephp-12/
>
>  - S
>
>
>
>
> On 25 February 2011 00:21, Krissy Masters wrote:
>
>> Maybe I read it wrong back in the day but something idles in my head about
>> requestAction being bad. Is this true or still in effect? I am using 1.3.7
>> and I think I remember reading back in 1.2 its better to not use that
>> function.
>>
>> “If used without caching requestAction can lead to poor performance. It is
>> rarely appropriate to use in a controller or model.”
>>
>> I have 1 element on 3 pages where I simply need to grab 4 fields from a db
>> for the element. The element is loaded originally on the first page left
>> side navigation column, and links load content into the main column so the
>> element is never refreshed since its on the side nav column except if
>> someone “open in new tab / window” on the link so the element has no data
>> because its originally loaded on the main page. So rather than build that
>> data call into each of those 3 pages I figured request would be the best
>> option.
>>
>> My Picasso below :)
>>
>>
>> Side Col  |   Main Col
>> ___
>> | nav => loads into main  |   content gets loaded here via ajax
>> |--|
>> |
>> | element |
>> |
>> 
>>
>>
>>
>> Just looking for some input on the matter.
>>
>> Thanks,
>>
>> K
>>
>> --
>> Our newest site for the community: CakePHP Video Tutorials
>> http://tv.cakephp.org
>> Check out the new CakePHP Questions site http://ask.cakephp.org and help
>> others with their CakePHP related questions.
>>
>>
>> To unsubscribe from this group, send email to
>> cake-php+unsubscr...@googlegroups.com For more options, visit this group
>> at http://groups.google.com/group/cake-php
>>
>
>  --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group
> at http://groups.google.com/group/cake-php
>

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: requestAction question

2011-02-24 Thread Sam Sherlock
Andy Gale mentions that requestAction was not an option for use in a large
scale site (in video on the tv site)

http://mark-story.com/posts/view/reducing-requestaction-use-in-your-cakephp-sites-with-fat-models

this article by teknoid is about menu specifically - I just found it &
bookmarked it
http://nuts-and-bolts-of-cakephp.com/2008/08/20/dynamic-menus-without-requestaction-in-cakephp-12/

 - S




On 25 February 2011 00:21, Krissy Masters wrote:

> Maybe I read it wrong back in the day but something idles in my head about
> requestAction being bad. Is this true or still in effect? I am using 1.3.7
> and I think I remember reading back in 1.2 its better to not use that
> function.
>
> “If used without caching requestAction can lead to poor performance. It is
> rarely appropriate to use in a controller or model.”
>
> I have 1 element on 3 pages where I simply need to grab 4 fields from a db
> for the element. The element is loaded originally on the first page left
> side navigation column, and links load content into the main column so the
> element is never refreshed since its on the side nav column except if
> someone “open in new tab / window” on the link so the element has no data
> because its originally loaded on the main page. So rather than build that
> data call into each of those 3 pages I figured request would be the best
> option.
>
> My Picasso below :)
>
>
> Side Col  |   Main Col
> ___
> | nav => loads into main  |   content gets loaded here via ajax
> |--|
> |
> | element |
> |
> 
>
>
>
> Just looking for some input on the matter.
>
> Thanks,
>
> K
>
> --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group
> at http://groups.google.com/group/cake-php
>

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


requestAction question

2011-02-24 Thread Krissy Masters
Maybe I read it wrong back in the day but something idles in my head about
requestAction being bad. Is this true or still in effect? I am using 1.3.7
and I think I remember reading back in 1.2 its better to not use that
function.

“If used without caching requestAction can lead to poor performance. It is
rarely appropriate to use in a controller or model.”

I have 1 element on 3 pages where I simply need to grab 4 fields from a db
for the element. The element is loaded originally on the first page left
side navigation column, and links load content into the main column so the
element is never refreshed since its on the side nav column except if
someone “open in new tab / window” on the link so the element has no data
because its originally loaded on the main page. So rather than build that
data call into each of those 3 pages I figured request would be the best
option.

My Picasso below :)


Side Col  |   Main Col
___
| nav => loads into main  |   content gets loaded here via ajax
|--|
|
| element |
|




Just looking for some input on the matter.

Thanks,

K

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: cookbook experience

2011-02-24 Thread rj
Well, originally the pages do not contain any Flash objects (viewing
the source). These elements are loaded afterwords and appended at the
end of the document with some (not always correct) absolute
positioning, e.g. on http://book.cakephp.org/#!/view/1529/Getting-Cake
Firebug reveals something like this attached to the DOM:
http://book.cakephp.org/theme/frosted/
js/ZeroClipboard.swf" id="ZeroClipboardMovie_1">

Why would the page load them when I don't have Flash enabled? Anyways,
it would be possible, within limits, to copy cleaned-up content to the
clipboard with pure Javascript and without using proprietary
technologies.

If the browser has limited access to the clipboard for Javascript I
could imagine something like the following:
Note: this is a quick and dirty hack, really ugly and it only works
with my favorite copy of Firefox  :-) (e.g. IE returns all code as one
single line)

A piece of html taken from that same URL above and slightly modified
(see my comments within < ! - - >), where an additional textarea
serves as a container for the cleaned-up code:

Regardless of how you downloaded it, place the code inside of your
DocumentRoot. Once finished, your directory setup should look
something like the following:


Copy to
Clipboard:


/path_to_document_root
/app
/
cake
/plugins
/
vendors
.htaccess
index.php
README
  



And here goes some rudimentary JQuery code:
  
$(document).ready(function(){
$('textarea.copycontainer').mouseenter(copyCode);
});

function copyCode(){
var theCode = $(this).parent().parent().find('ol').text();
$(this).val(theCode);
$(this).focus();
$(this).select();
}

and a bit of style:

.copycontainer{
width:100px;
height:1em;
margin:0px 0px 0px 5px;
padding:0px;
font-size:15px;
overflow:hidden;
border:1px solid blue;
}


Now you will see a small blue area to the right of the "Copy to the
clipboard" text. Move your mouse cursor onto this element, rightclick
and copy. Since you copy youself, your browser should not complain. If
he still does... :-)

As mentioned above, this is not tested, does not look very cool, but
something like that should be pretty robust if finetuned a bit.

On Feb 24, 1:57 pm, cricket  wrote:
> On Wed, Feb 23, 2011 at 6:36 PM, Ryan Schmidt
>
>  wrote:
> > On Feb 23, 2011, at 13:14, rj wrote:
>
> >> One last note: getting rid of the flash elements which are emedded by
> >> default would also help for usability.
> >> I suggest to load them by ajax only if Javscript detects that Flash is
> >> really available, otherwise just do nothing. The page would be leaner
> >> and cleaner, and people having disabled Flash for any reason will not
> >> be bothered with non-functional embeddd objects partly covering the
> >> text.
> >> Anyway, as far as I can see they only provide the copy to clipboard
> >> functionality and most of us know how to copy and paste code with the
> >> mouse cursor, don't we :-)
>
> > I too have been annoyed by these Flash boxes, since I too use a Flash 
> > blocker. I suppose I'll just tell it to allow Flash from the cookbook, 
> > because you actually do need it to copy the text properly. If you try to 
> > copy the text by selecting it and copying it normally, it does not come out 
> > right when pasted. Depending on the browser I copy from and the editor I 
> > paste into, either the line numbers are pasted as well, or they are turned 
> > into bullets, or newlines or indentation are deleted, or some combination 
> > of these, none of which results in readable and functional code.
>
> I don't see any Flash at all. Which boxes? The code samples? They're
> just plain old CSS and JQuery.
>
> ... which don't work for me (the "copy" bit). :-)

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: hiding link from certain users.

2011-02-24 Thread Stephen
Your passwords will work if you don't use the auth component, if you're not
using the auth component, $session->read('Auth.User.superuser'); will not
work. You need to save it manually.

In your example you say "if ($user = 'superuser') {"

You need to do what Ryan says (if you use Auth).

On 24 February 2011 19:00, cricket  wrote:

> On Wed, Feb 23, 2011 at 10:22 PM, Kid Hell 
> wrote:
> > thank you for your reply..but i still can't get it right.. I'm a slow
> > learner. Can you please explain deeper on the (Auth.User.group_id') part.
> >
> > this is what the table in db looks like
> >
> > id  usrname
> > pass  superuser
> >
> >  1   jill
> > 123451
> >  2   john
> > 543210
> >  3   kurt  32145
> >0
>
>
> I presume these are example data but, to just to be clear, the
> passwords must be hashed before saving to the DB.
>
> --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group
> at http://groups.google.com/group/cake-php
>



-- 
Kind Regards
 Stephen

 http://www.ninjacodermonkey.co.uk

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Account activation through email

2011-02-24 Thread Stephen
The article should be more clear if it isn't already I suppose.

Good luck!

On 24 February 2011 23:23, Rob  wrote:

> Thanks, that helped a lot...looks like I have a lot more to learn here.
>
> --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group
> at http://groups.google.com/group/cake-php
>



-- 
Kind Regards
 Stephen

 http://www.ninjacodermonkey.co.uk

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Account activation through email

2011-02-24 Thread Rob
Thanks, that helped a lot...looks like I have a lot more to learn here.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Account activation through email

2011-02-24 Thread Stephen
Then you can just do

if($this->Auth->user($this->data)) {
   .. Login fine
} else {
   ..Login failed
]

You need to set $this->Auth->autoRedirect = false in your beforeFilter (app
controller) to be able to edit the login action.

On 24 February 2011 23:02, Stephen  wrote:

> http://book.cakephp.org/view/1268/userScope
>
> Place it in your App Controller, in beforeFilter
>
> i.e.
>
> $this->Auth->userScope = array('User.active' => 1);
>
> If active is not set to 1 it will not allow the user to login.
>
> Much easier.
>
>
> On 24 February 2011 21:24, Rob  wrote:
>
>> I'm following this tutorial to add email account activation
>>
>> http://www.jonnyreeves.co.uk/2008/06/cakephp-activating-user-account-via-email/
>> I'm using cake 1.3 and I'm using auth and acl in my application
>>
>> Now onto the problem.
>>
>> on login, I want to check to see if the user's account has been
>> activated, so following the tutorial I add
>> if ($this->data) {
>>// Use the AuthComponent’s login action
>>if ($this->Auth->login($this->data)) {
>>// Retrieve user data
>>$results = $this->User-
>> >find(array(‘User.username’ => $this->data[‘User’][‘username’]),
>> array(‘User.active’), null, false);
>>// Check to see if the User’s account
>> isn’t active
>>if ($results[‘User’][‘active’] == 0) {
>>// Uh Oh!
>>$this->Session->setFlash(‘Your
>> account has not been activated yet!’);
>>$this->Auth->logout();
>>$this->redirect(‘/users/
>> login’);
>>}
>>// Cool, user is active, redirect post
>> login
>>else {
>>$this->redirect(‘/’);
>>}
>>}
>>}
>>
>> to my login function in my users_controller.  The only problem is that
>> it's never entering that if statement.  It seems that it doesn't think
>> $this->data has anything in it.
>>
>> I'm thinking this has something to do with the automagic elements of
>> Auth, but I'm not sure.
>>
>> Anyone have any ideas why this is happening
>>
>> --
>> Our newest site for the community: CakePHP Video Tutorials
>> http://tv.cakephp.org
>> Check out the new CakePHP Questions site http://ask.cakephp.org and help
>> others with their CakePHP related questions.
>>
>>
>> To unsubscribe from this group, send email to
>> cake-php+unsubscr...@googlegroups.com For more options, visit this group
>> at http://groups.google.com/group/cake-php
>>
>
>
>
> --
> Kind Regards
>  Stephen
>
>  http://www.ninjacodermonkey.co.uk
>
>
>


-- 
Kind Regards
 Stephen

 http://www.ninjacodermonkey.co.uk

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Account activation through email

2011-02-24 Thread Stephen
http://book.cakephp.org/view/1268/userScope

Place it in your App Controller, in beforeFilter

i.e.

$this->Auth->userScope = array('User.active' => 1);

If active is not set to 1 it will not allow the user to login.

Much easier.

On 24 February 2011 21:24, Rob  wrote:

> I'm following this tutorial to add email account activation
>
> http://www.jonnyreeves.co.uk/2008/06/cakephp-activating-user-account-via-email/
> I'm using cake 1.3 and I'm using auth and acl in my application
>
> Now onto the problem.
>
> on login, I want to check to see if the user's account has been
> activated, so following the tutorial I add
> if ($this->data) {
>// Use the AuthComponent’s login action
>if ($this->Auth->login($this->data)) {
>// Retrieve user data
>$results = $this->User-
> >find(array(‘User.username’ => $this->data[‘User’][‘username’]),
> array(‘User.active’), null, false);
>// Check to see if the User’s account
> isn’t active
>if ($results[‘User’][‘active’] == 0) {
>// Uh Oh!
>$this->Session->setFlash(‘Your
> account has not been activated yet!’);
>$this->Auth->logout();
>$this->redirect(‘/users/
> login’);
>}
>// Cool, user is active, redirect post
> login
>else {
>$this->redirect(‘/’);
>}
>}
>}
>
> to my login function in my users_controller.  The only problem is that
> it's never entering that if statement.  It seems that it doesn't think
> $this->data has anything in it.
>
> I'm thinking this has something to do with the automagic elements of
> Auth, but I'm not sure.
>
> Anyone have any ideas why this is happening
>
> --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group
> at http://groups.google.com/group/cake-php
>



-- 
Kind Regards
 Stephen

 http://www.ninjacodermonkey.co.uk

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: DEBUG=2: My error500 shows; DEBUG=0: I get "not found". --psybear

2011-02-24 Thread Jamie
Just curious, why the "--psybear" at the end of your message subjects?
Google does put in your name and email address for you. ;)

On Feb 24, 8:59 am, Joshua Muheim  wrote:
> According to the following article, this seems to be the normal CakePHP-way.
>
> http://nuts-and-bolts-of-cakephp.com/2008/08/29/dealing-with-errors-i...
>
> So, errors are only displayed to the programmer while developing, and
> not to the user while surfing. If you want to display something
> different to the default 404 when an error happens, you should call
> $this->render('some_error') or something like that.
>
>
>
>
>
>
>
> On Wed, Jan 26, 2011 at 9:44 AM, Joshua Muheim  wrote:
> > Thanks for your reply, Steve. I have created app/app_controller.php
> > with the following content:
>
> >  > class AppError extends ErrorHandler {
> >  function error500($params) {
> >    header('HTTP/1.1 500 Internal Server Error');
> >    $this->_outputMessage('error500');
> >  }
> > }
> > ?>
>
> > But it still doesn't work, although the AppError handler is taken into
> > account: when placing a die("hello"); into the error500() method, then
> > having DEBUG set to 2 displays "hello", but DEBUG set to 0 displays
> > the old "Not found" error message... What am I missing?
>
> > On Tue, Jan 25, 2011 at 5:50 PM, Steve  wrote:
> >> I think you need to provide a appError class. The default code turns off
> >> the error routing when you disable DEBUG ( set it to 0 ) so it looks for
> >> a URL which your server is correctly reporting the absence of.
>
> >>http://book.cakephp.org/view/154/Error-Handling
>
> >> On Tue, 2011-01-25 at 08:21 -0800, psybear83 wrote:
> >>> Hey everybody
>
> >>> When having DEBUG set to 2 (or 1), my sweet little error500 is shown
> >>> correctly.
>
> >>> SomeController extends AppController {
> >>>       function _error500() {
> >>>         $this->cakeError('error500');
> >>>         exit;
> >>>       }
> >>> }
>
> >>> But when it's set to 0, then I'm just getting a plain "Error: The
> >>> requested address 'xxx' was not found on this server."
>
> >>> Any idea what's going (wr)on(g)? Please give me a hint - as soon as
> >>> this is working my website is ready for being released in beta-
> >>> testing. :-)
>
> >>> Thanks
> >>> Josh
>
> >> --
> >> Our newest site for the community: CakePHP Video 
> >> Tutorialshttp://tv.cakephp.org
> >> Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help 
> >> others with their CakePHP related questions.
>
> >> To unsubscribe from this group, send email to
> >> cake-php+unsubscr...@googlegroups.com For more options, visit this group 
> >> athttp://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Account activation through email

2011-02-24 Thread Rob
I'm following this tutorial to add email account activation
http://www.jonnyreeves.co.uk/2008/06/cakephp-activating-user-account-via-email/
I'm using cake 1.3 and I'm using auth and acl in my application

Now onto the problem.

on login, I want to check to see if the user's account has been
activated, so following the tutorial I add
if ($this->data) {
// Use the AuthComponent’s login action
if ($this->Auth->login($this->data)) {
// Retrieve user data
$results = $this->User-
>find(array(‘User.username’ => $this->data[‘User’][‘username’]),
array(‘User.active’), null, false);
// Check to see if the User’s account
isn’t active
if ($results[‘User’][‘active’] == 0) {
// Uh Oh!
$this->Session->setFlash(‘Your
account has not been activated yet!’);
$this->Auth->logout();
$this->redirect(‘/users/
login’);
}
// Cool, user is active, redirect post
login
else {
$this->redirect(‘/’);
}
}
}

to my login function in my users_controller.  The only problem is that
it's never entering that if statement.  It seems that it doesn't think
$this->data has anything in it.

I'm thinking this has something to do with the automagic elements of
Auth, but I'm not sure.

Anyone have any ideas why this is happening

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Numeric vs integer vs digit validation

2011-02-24 Thread euromark
i agree that it wouldnt hurt to specify the rules for numeric values a
little bit more precisely :)
if you provide a ticket and a patch, i am sure it will be considered
for 2.0


On 24 Feb., 09:19, Ryan Schmidt  wrote:
> On Feb 14, 2011, at 10:12, John Andersen wrote:
>
> > You always have the opportunity to make your own validation rules, see
> > the CakePHP book at:
> >http://book.cakephp.org/view/1179/Custom-Validation-Rules
>
> > I don't think the CakePHP team can take into account all the possible
> > kinds of validation rules that we would like to have.
> > But feel free to make the suggestion to the team for the validation
> > rules, that you would like to see in future CakePHP versions.
>
> I know that I can define my own validation rules; I have already done so in 
> my project.
>
> I'm not asking for CakePHP to provide all possible validation rules for every 
> possible scenario; I'm asking it to provide the most common types of 
> validation rules that almost every project will need to use. Integer and 
> especially unsigned integer validation are in that category. If I am building 
> a ticket-ordering site where I want to know from the user how many tickets 
> they want, then I will have an unsigned integer field in my database for 
> that, and I will want unsigned integer validation on it. But when I bake this 
> model, CakePHP will suggest that I would want "numeric" validation on it. If 
> a user enters that they want 3.14 tickets, the numeric validation will allow 
> that (which will, when saved into the database, be truncated to 3), whereas I 
> would want my model's validation to display an error message to the user 
> instead.
>
> I am a new CakePHP user; the humor of the "female needs help!" thread 
> notwithstanding, I find it entirely relevant to mention this, since it means 
> I do not know if I am using CakePHP correctly. Bug trackers are great places 
> to write up things which are bugs; I was not yet sure whether the behavior I 
> observed was a bug or missing feature (though it certainly seemed like it to 
> me) or merely me not knowing how it is meant to be used. The reasons I wrote 
> to this list were:
>
>  * to verify whether I have understood correctly that CakePHP does not have 
> this (to me) basic and fundamental feature built in;
>  * to inquire whether anybody else has noticed this before;
>  * to express surprise that, when CakePHP is all about tests, this deficiency 
> has not been discovered in testing;
>  * to gain further input from the community before deciding this is in fact a 
> bug that I should write a bug report about

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


RE: afterDelete not running as intended

2011-02-24 Thread Krissy Masters
Image->find('all',
$conditions);

change to:

$images = $this->find('all', $conditions);

K

-Original Message-
From: cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] On Behalf
Of adam_g2000
Sent: Thursday, February 24, 2011 4:36 PM
To: CakePHP
Subject: Re: afterDelete not running as intended

Hi again Jeremy!

Thanks for that, there's my sanity check! I've done that, it's now
sitting in my Images Model. Unfortunately, nothing happens still

Here's the entire model, am I still doing something stupid?

 array(
'notempty' => array(
'rule' => array('notempty')
),
),
);

function afterDelete() {
// Re-sort orders to remove the 'hole'
// Create an array of the image table contents of IDs and
Orders.
$conditions = array(
'fields' =>
array('id','order'),
'order' => 'Image.order ASC'
);
$images = $this->Image->find('all', $conditions);
//Loop through looking for order/count disparity and tidying
up when
disparity is found.
$counter = 1;
foreach ($images as $image):
$image['Image']['order'] = $counter;
$this->Image->save($image, false,
array('id','order'));
$counter++;
endforeach;
}
}
?>

On Feb 24, 7:22 pm, Jeremy Burns | Class Outfit
 wrote:
> Is this in a model or a controller? I am guessing it's in a controller
because you have a redirect statement. To make it run as afterDelete you
need to move it into the model (afterDelete is a model callback) and then
you'd need to remove the redirect statement because it will error.
>
> Jeremy Burns
> Class Outfit
>
> jeremybu...@classoutfit.comhttp://www.classoutfit.com
>
> On 24 Feb 2011, at 03:36, adam_g2000 wrote:
>
>
>
> > Hi Guys,
>
> > I have this method I've written...
>
> > function tidyup() {
> >    //Re-sort orders to remove the 'hole'
> >    // Create an array of the image table contents of IDs and Orders.
> >    $conditions = array(
> >                                    'fields' => array('id','order'),
> >                                    'order' => 'Image.order ASC'
> >    );
> >    $images = $this->Image->find('all', $conditions);
> >    //Loop through looking for order/count disparity and tidying up when
> > disparity is found.
> >    $counter = 1;
> >    foreach ($images as $image):
> >            if ($image['Image']['order'] != $counter) {
> >                    $image['Image']['order'] = $counter;
> >                    $this->Image->save($image, false,
array('id','order'));
> >            }
> >            $counter++;
> >    endforeach;
> >    $this->redirect(array('action' => 'index'));
> > }
>
> > ...to reorder a list of Images in a database table once one is
> > deleted. This works perfectly.
>
> > However, what I really want to do is have it triggered automatically
> > once an Image is deleted.
>
> > So I would expect just changing function tidyup to function
> > afterDelete should work perfectly. When I do that, the function never
> > runs.
>
> > Can I get a sanity check please? Can anyone spot my error?
>
> > Thanks in advance for any offers of assistance.
>
> > --
> > Our newest site for the community: CakePHP Video
Tutorialshttp://tv.cakephp.org
> > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help
others with their CakePHP related questions.
>
> > To unsubscribe from this group, send email to
> > cake-php+unsubscr...@googlegroups.com For more options, visit this group
athttp://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help
others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at
http://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: afterDelete not running as intended

2011-02-24 Thread adam_g2000
Hi again Jeremy!

Thanks for that, there's my sanity check! I've done that, it's now
sitting in my Images Model. Unfortunately, nothing happens still

Here's the entire model, am I still doing something stupid?

 array(
'notempty' => array(
'rule' => array('notempty')
),
),
);

function afterDelete() {
// Re-sort orders to remove the 'hole'
// Create an array of the image table contents of IDs and 
Orders.
$conditions = array(
'fields' => array('id','order'),
'order' => 'Image.order ASC'
);
$images = $this->Image->find('all', $conditions);
//Loop through looking for order/count disparity and tidying up 
when
disparity is found.
$counter = 1;
foreach ($images as $image):
$image['Image']['order'] = $counter;
$this->Image->save($image, false, array('id','order'));
$counter++;
endforeach;
}
}
?>

On Feb 24, 7:22 pm, Jeremy Burns | Class Outfit
 wrote:
> Is this in a model or a controller? I am guessing it's in a controller 
> because you have a redirect statement. To make it run as afterDelete you need 
> to move it into the model (afterDelete is a model callback) and then you'd 
> need to remove the redirect statement because it will error.
>
> Jeremy Burns
> Class Outfit
>
> jeremybu...@classoutfit.comhttp://www.classoutfit.com
>
> On 24 Feb 2011, at 03:36, adam_g2000 wrote:
>
>
>
> > Hi Guys,
>
> > I have this method I've written...
>
> > function tidyup() {
> >    //Re-sort orders to remove the 'hole'
> >    // Create an array of the image table contents of IDs and Orders.
> >    $conditions = array(
> >                                    'fields' => array('id','order'),
> >                                    'order' => 'Image.order ASC'
> >    );
> >    $images = $this->Image->find('all', $conditions);
> >    //Loop through looking for order/count disparity and tidying up when
> > disparity is found.
> >    $counter = 1;
> >    foreach ($images as $image):
> >            if ($image['Image']['order'] != $counter) {
> >                    $image['Image']['order'] = $counter;
> >                    $this->Image->save($image, false, array('id','order'));
> >            }
> >            $counter++;
> >    endforeach;
> >    $this->redirect(array('action' => 'index'));
> > }
>
> > ...to reorder a list of Images in a database table once one is
> > deleted. This works perfectly.
>
> > However, what I really want to do is have it triggered automatically
> > once an Image is deleted.
>
> > So I would expect just changing function tidyup to function
> > afterDelete should work perfectly. When I do that, the function never
> > runs.
>
> > Can I get a sanity check please? Can anyone spot my error?
>
> > Thanks in advance for any offers of assistance.
>
> > --
> > Our newest site for the community: CakePHP Video 
> > Tutorialshttp://tv.cakephp.org
> > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help 
> > others with their CakePHP related questions.
>
> > To unsubscribe from this group, send email to
> > cake-php+unsubscr...@googlegroups.com For more options, visit this group 
> > athttp://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: afterDelete not running as intended

2011-02-24 Thread adam_g2000
Hi Krissy,

Thanks for that tip - once I've solved my problem I'll definitely
improve the solution with your tip in mind!

Adam.

On Feb 24, 8:11 pm, "Krissy Masters" 
wrote:
> Not so much related to your post but I noticed something so tip for you:
>
> I do the same thing delete an ordered item 1,2,3,4,5,6 delete #4 so I grab
> the Model.order I am deleting and updateAll where Model.order is greater
> than 4 for this example saving un-necessary save's 1,2,3 never changed so
> why resave them :) Not a big deal but imagine hundreds of users re-ordering
> stuff constantly with hundreds of records being re-ordered. Save the db the
> trouble.
>
> $this->$currentModel->updateAll(array(
>         $currentModel.'.order' => $currentModel.'.order-1'), array(
>                 $currentModel.'.user_id' => $this->owner_id,
>                 $currentModel.'.order >' =>  $record[$currentModel]['order']
> ));
>
> K
>
>
>
> -Original Message-
> From: cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] On Behalf
>
> Of adam_g2000
> Sent: Thursday, February 24, 2011 12:07 AM
> To: CakePHP
> Subject: afterDelete not running as intended
>
> Hi Guys,
>
> I have this method I've written...
>
> function tidyup() {
>         //Re-sort orders to remove the 'hole'
>         // Create an array of the image table contents of IDs and Orders.
>         $conditions = array(
>                                         'fields' => array('id','order'),
>                                         'order' => 'Image.order ASC'
>         );
>         $images = $this->Image->find('all', $conditions);
>         //Loop through looking for order/count disparity and tidying up when
> disparity is found.
>         $counter = 1;
>         foreach ($images as $image):
>                 if ($image['Image']['order'] != $counter) {
>                         $image['Image']['order'] = $counter;
>                         $this->Image->save($image, false,
> array('id','order'));
>                 }
>                 $counter++;
>         endforeach;
>         $this->redirect(array('action' => 'index'));
> }
>
> ...to reorder a list of Images in a database table once one is
> deleted. This works perfectly.
>
> However, what I really want to do is have it triggered automatically
> once an Image is deleted.
>
> So I would expect just changing function tidyup to function
> afterDelete should work perfectly. When I do that, the function never
> runs.
>
> Can I get a sanity check please? Can anyone spot my error?
>
> Thanks in advance for any offers of assistance.
>
> --
> Our newest site for the community: CakePHP Video 
> Tutorialshttp://tv.cakephp.org
> Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help
> others with their CakePHP related questions.
>
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group 
> athttp://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Model data appears to unset after save, is this correct?

2011-02-24 Thread cricket
On Thu, Feb 24, 2011 at 3:43 AM, Greg Skerman  wrote:
> Hi,
>
> I've been working on a very simple app to upload and resize some images, and
> name the file in accordance with some information that has been provided in
> a form.
>
> To do this, my model has a public method "createFilename", which relies on
> $this->data to build the filename in accordance with the provided business
> rules.
>
> It was all working fine, until I connected the model to a database table and
> started also saving the meta-data now it appears $this->data is being
> unset for subsequent calls to the method.
>
> The method is simple enough:
>
> public function createFilename() {
>
> CakeLog::write('debug', 'photo name is '.
> $this->data['Photo']['name']);
>
> $name = $this->data['Photo']['name'];
>
> $level = $this->data['Photo']['level'];
>
> $category = $this->data['Photo']['category'];
>
> $month = strtoupper($this->data['Photo']['month']);
>
>
> return $level . $category . $month . $name . '.jpg';
>
> }
>
>
> According to the information that I log, in the 4 times this method is
> called during the processing of the image, the first time
> $this->data['Photo']['name']  contains data, and then each subsequent call
> is empty.
>
> The first time the method is called is at validation to prevent duplicate
> files with the same metadata being created, and this seems to be working
> fine, but then the following times (which are used for naming the file after
> it has been manipulated, moving the file out of the TMP directory into the
> uploaded images directory, and including the filename in an email
> attachment, $this->data appears to be empty.

I realise, from your other post, that you're not doing calling that
method repeatedly anymore. It's really inefficient to do that.

The way I've approached this is to use a FileHandlerComponent and
ImageHandlerComponent. Any controller that deals with an upload calls
__handleUpload() after saving the record. The first component deals
with moving the file to the correct location and the second with
resizing. I split them into separate components because I deal with a
lot of non-image uploads.

Example from FilesController:

private function __handleImageUpload()
{
$this->FileHandler->setModelName('Link');
$this->FileHandler->setBase(WWW_ROOT);
$this->FileHandler->setSubDirectory('files/links');

if ($this->FileHandler->upload('upload', false))
{
$upload_data = $this->FileHandler->getUploadData();

/* create a reasonably-sized image
 */
if (!empty($upload_data))
{   
/* resize if necessary
 */
$img_data = $this->ImageHandler->apply(
array_merge($this->Link->image_settings, 
array('basename' =>
$upload_data['basename'])),

$this->FileHandler->getBase().$upload_data['directory'].DS.$upload_data['basename'],

$upload_data['directory'].DS.$upload_data[0]['basename']
);

/* Save image details
 */
if (is_array($img_data) && !empty($img_data))
{
$data = array(
'Link' => array(
'id' => $this->Link->id,
'directory' => 
$upload_data[0]['directory'],
'basename' => 
$img_data['basename'],
'extension' => 
$img_data['extension'],
'type' => $img_data['type'],
'size' => $img_data['size'],
'width' => $img_data['width'],
'height' => $img_data['height']
)
);

/* see if there's already an image
 */
$old_image = $this->Link->find(
'first',
array(
'conditions' => array('id' => 
$this->Link->id),
'recursive' => -1
)
);

if ($this->Link->save($data, false))
{
if 
(isset($old_image['Link']['ba

Re: hiding link from certain users.

2011-02-24 Thread cricket
On Wed, Feb 23, 2011 at 10:22 PM, Kid Hell  wrote:
> thank you for your reply..but i still can't get it right.. I'm a slow
> learner. Can you please explain deeper on the (Auth.User.group_id') part.
>
> this is what the table in db looks like
>
> id  usrname
> pass  superuser
>
>  1   jill
> 12345    1
>  2   john
> 54321    0
>  3   kurt  32145
>    0


I presume these are example data but, to just to be clear, the
passwords must be hashed before saving to the DB.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: cookbook experience

2011-02-24 Thread cricket
On Wed, Feb 23, 2011 at 6:36 PM, Ryan Schmidt
 wrote:
> On Feb 23, 2011, at 13:14, rj wrote:
>>
>> One last note: getting rid of the flash elements which are emedded by
>> default would also help for usability.
>> I suggest to load them by ajax only if Javscript detects that Flash is
>> really available, otherwise just do nothing. The page would be leaner
>> and cleaner, and people having disabled Flash for any reason will not
>> be bothered with non-functional embeddd objects partly covering the
>> text.
>> Anyway, as far as I can see they only provide the copy to clipboard
>> functionality and most of us know how to copy and paste code with the
>> mouse cursor, don't we :-)
>
> I too have been annoyed by these Flash boxes, since I too use a Flash 
> blocker. I suppose I'll just tell it to allow Flash from the cookbook, 
> because you actually do need it to copy the text properly. If you try to copy 
> the text by selecting it and copying it normally, it does not come out right 
> when pasted. Depending on the browser I copy from and the editor I paste 
> into, either the line numbers are pasted as well, or they are turned into 
> bullets, or newlines or indentation are deleted, or some combination of 
> these, none of which results in readable and functional code.

I don't see any Flash at all. Which boxes? The code samples? They're
just plain old CSS and JQuery.

... which don't work for me (the "copy" bit). :-)

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Easiest way to get data from a model (better way than $model->data['modelname']['field'])?

2011-02-24 Thread cricket
One slight change: you're $model param is superfluous. There's no need
to pass the model as this is the AppModel. Just use $this when
referencing it.

I'd also check if $this->data exists before doing anything.

OK, one other possibility:

public function data()
{
if (empty($this->data)) return null;

$res = Set::extract(
'/' . implode('/', func_get_args()),
$this->data
);

// ...

return $res;
}

I didn't return immediately because I know that, in some cases, $res
is going to be formatted in unhelpful ways. So some further work would
be needed.

On Thu, Feb 24, 2011 at 11:30 AM, Joshua Muheim  wrote:
> Just in case somebody is interested... I have added a small method
> data() that works a little nicer in my opinion than the standard way
> of accessing the data array's values is...
>
> So instead of $this->Model->data['User']['name'] you can just call
> $this->Model->data('name')... saves you a few keystrokes. Most of you
> guys will say this is not necessary... ;-) And maybe you're right. But
> here it goes...
>
>  // Put this into your AppModel
>  /**
>   * Makes returning model data convenient.
>   *
>   * Examples:
>   * - data('name') returns $model->data[]['name']
>   * - data('Group') returns $model->data['Group']
>   * - data('Groups') returns $model->data['Groups']
>   * - data('Group', 'id') returns $model->data['Group']['id']
>   *
>   * @param $model Model
>   * @return mixed
>   */
>  function data(&$model) {
>    $association = null;
>    $field = null;
>
>    $params = func_get_args();
>    array_shift($params); // Remove the pointer to the model (first argument)
>
>    $paramsCount = count($params);
>    $association = null;
>    $field = null;
>    if($paramsCount == 2) {
>      $association = $params[0];
>      $field = $params[1];
>    } elseif($paramsCount == 1) {
>      if(ctype_upper($params[0][0])) {
>        $association = $params[0];
>      } else {
>        $association = $model->name;
>        $field = $params[0];
>      }
>    }
>
>    if(isset($model->data[$association])) {
>      if(!empty($field)) {
>        if(isset($model->data[$association][$field])) {
>          return $model->data[$association][$field];
>        }
>      } else {
>        if(isset($model->data[$association])) {
>          return $model->data[$association];
>        }
>      }
>    }
>
>    return false;
>  }
>
> On Wed, Oct 20, 2010 at 1:14 AM, cricket  wrote:
>> On Tue, Oct 19, 2010 at 7:03 PM, cricket  wrote:
>>> On Tue, Oct 19, 2010 at 5:53 AM, psybear83  wrote:
 Hi everybody

 Sorry for this newbish question, but I don't seem to find much about
 this (although I should, I guess).

 $m = $this->Model->find(1);
>>>
>>> Since when does find() work like that? What version are you using?
>>>
 echo $m->data['Model']['something];
>>>
>>> How are you getting an object returned from find()? Did I miss something?
>>>
>>
>> Whoops! Please disregard. I didn't understand that you were
>> *suggesting* it be done this way.
>>
>> Check out the new CakePHP Questions site http://cakeqs.org and help others 
>> with their CakePHP related questions.
>>
>> You received this message because you are subscribed to the Google Groups 
>> "CakePHP" group.
>> To post to this group, send email to cake-php@googlegroups.com
>> To unsubscribe from this group, send email to
>> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
>> http://groups.google.com/group/cake-php?hl=en
>>
>
> --
> Our newest site for the community: CakePHP Video Tutorials 
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help 
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php
>

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: any way to omit app/webroot when request image file or directory inside it

2011-02-24 Thread cricket
On Thu, Feb 24, 2011 at 12:52 PM, mohammad Al-Ani
 wrote:
> hi all..
>
> hope you do well
>
> I use cakephp from along and I faced a problem that I think it's a security
> issue
>
> when I request any file or directory that settle inside webroot directory.
> The URL automatically show the app/wedroot slug
>
> ex:
>
> request
>
>     www.mydomian.com/css/main.css
>
> change in browser to
>
>     www.mydomian.com/app/webroot/css/main.css
>
> I thing this shows up that I used cakephp. and I find it unprofessional way
> to leave such behavior

In the config for this virtual host:
-- snip --
DocumentRoot /path/to/site/app/webroot


Options FollowSymLinks
# disable .htaccess
AllowOverride None
Order allow,deny
Allow from all

DirectoryIndex index.php index.html

# copied from app/webroot/.htaccess

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]


-- snip --

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: file upload with miles johnsons upload plugin - without model

2011-02-24 Thread Miles J
Your form is posting to a completely different url. Try setting this:

echo $form->create('Model', array('type' => 'file', 'url' =>
array('controller'=>'pages','action'=>'display', 'upload')));

On Feb 24, 9:05 am, soymartinus  wrote:
> Hi
> i'm new to cakephp and can't get miles johnsons upload plugin 
> (http://www.milesj.me/resources/script/uploader-plugin) to work.
>
> i don't use/need a database for the upload form.
> so i created the upload.ctp in app/views/pages
>
> echo $form->create('Model', array('type' => 'file'));
> echo $form->input('fileName', array('type' => 'file'));
> echo $form->end('Upload');
>
> and added to the pages_controller the
> function upload() like explained in the tutorial on miles webpage.
>
> in routes.php i put
> Router::connect('/upload',
> array('controller'=>'pages','action'=>'display', 'upload'));
>
> thats what i added to the pages_controller:
>
> //uploader plugin
> var $components = array('Uploader.Uploader');
> var $actsAs = array('Uploader.FileValidation');
>
> function upload() {
>         //http://www.milesj.me/resources/script/uploader-plugin
>         $this->set('testvar', "hello world");
>         $this->Uploader->uploadDir = 'files/uploads/';
>         $this->Uploader->enableUpload = true;
>         $this->Uploader->maxFileSize = '8M'; // 8 Megabytes
>         $this->Uploader->maxNameLength = 40;
>         //$this->Uploader->mime('image', 'gif', 'image/gif');
>         //$this->Uploader->delete('files/uploads/filename.jpg');
>
>         if (!empty($this->data)) {
>                 if ($data = $this->Uploader->upload('fileName', 
> array('overwrite' =>
> true, 'name' => 'new_fileName'))){
>                         debug($data);
>                 }
>         }
>
> }
>
> when i now want to upload a file, i get always the error:
> Error: ModelsController could not be found.
>
> thank you very much in advance for any help
>
> regards from spain, martin

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: any way to omit app/webroot when request image file or directory inside it

2011-02-24 Thread Miles J
You can try setting up some apache mod_rewrite rules.

But on top of that, anyone can see that you are sing Cake by checking
your form structure, or that you are using named params.

On Feb 24, 9:52 am, mohammad Al-Ani  wrote:
> hi all..
>
> hope you do well
>
> I use cakephp from along and I faced a problem that I think it's a security
> issue
>
> when I request any file or directory that settle inside webroot directory.
> The URL automatically show the app/wedroot slug
>
> ex:
>
> request
>
>    * *www.mydomian.com/css/main.css
>
> change in browser to
>
>    www.mydomian.com/*app/webroot*/css/main.css
>
> I thing this shows up that I used cakephp. and I find it unprofessional way
> to leave such behavior
>
> any suggestions, idea...
>
> thanks for your time : )

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Changing Model Conditions in another controller

2011-02-24 Thread Alex Ciobanu

On 2/24/2011 10:40 AM, heohni wrote:

When I call $members = $this->Member->find('all');
Cake performs 2 statements.
1. to get all member results
2. to get all subscription results


Use the Containable behavior and pass conditions to the related model.

http://book.cakephp.org/view/1323/Containable#Containing-deeper-associations-1325

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.



To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Changing Model Conditions in another controller

2011-02-24 Thread code_falcon
Hi heohni!

You could use the Model class' bindModel() method to change the
hasMany condition on the fly. In your case, you must use an option
like this: 'conditions' => array('Subscription.active' => TRUE).

I don't know exactly what is your subscriptions table structure. Then,
you should change the field 'Subscription.active' for the correct one.

An example is showed below:

$this->Member->bindModel(array('hasMany' => array('Subscription' =>
array('conditions' => array('Subscription.active' => TRUE, FALSE);
$members = $this->Member->find('all');

On Feb 24, 5:40 am, heohni 
wrote:
> Hi,
>
> I have a Member model with hasMany Subscriptions.
>
> Now, in another controller, I am calling the Member Model to give me
> some data.
> I want now to create a find() which lists me all active members with
> their active subscriptions.
>
> Getting the active Members is easy, as this information is stored
> within the members table.
> But how can I get now only the  active subscriptions for this
> particular member?
>
> When I call $members = $this->Member->find('all');
> Cake performs 2 statements.
> 1. to get all member results
> 2. to get all subscription results
>
> To get only active members I can set conditions within the find ()
> method.
> But how can I access the 2. query conditions which is selecting the
> subscription results?
>
> Please advise, thanks in advance!

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Folders inside img/

2011-02-24 Thread Dr. Loboto
Wrong filename/path. Cake catches all requests to non-existent files.

On 23 фев, 17:51, "Aleksandr (cligs.ee)"
 wrote:
> I created a folder cropped_images inside img folder and uploaded my
> photos there. But when I try to open them in the browser, Apache
> decides to tunnel the request through cake instead of serving static
> files, which gives me a warning that I'm missing ImgController.
>
> How can I fix it?

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: model relation problem

2011-02-24 Thread Alex Ciobanu

On 2/24/2011 6:54 PM, pang wrote:

The  problem is `Friend`.`friend_id` is left joined with
`Friend`.`id`. How to solve this problem ?


Give it a different alias.

E.g.:
public $belongsTo = array(
'MyFriend' => array('className' => 'Friend',
'foreignKey' => 'friend_id',
)
);

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.



To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


any way to omit app/webroot when request image file or directory inside it

2011-02-24 Thread mohammad Al-Ani
hi all..

hope you do well

I use cakephp from along and I faced a problem that I think it's a security
issue

when I request any file or directory that settle inside webroot directory.
The URL automatically show the app/wedroot slug

ex:

request

   * *www.mydomian.com/css/main.css

change in browser to

www.mydomian.com/*app/webroot*/css/main.css

I thing this shows up that I used cakephp. and I find it unprofessional way
to leave such behavior

any suggestions, idea...


thanks for your time : )

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


file upload with miles johnsons upload plugin - without model

2011-02-24 Thread soymartinus
Hi
i'm new to cakephp and can't get miles johnsons upload plugin (
http://www.milesj.me/resources/script/uploader-plugin ) to work.

i don't use/need a database for the upload form.
so i created the upload.ctp in app/views/pages

echo $form->create('Model', array('type' => 'file'));
echo $form->input('fileName', array('type' => 'file'));
echo $form->end('Upload');

and added to the pages_controller the
function upload() like explained in the tutorial on miles webpage.

in routes.php i put
Router::connect('/upload',
array('controller'=>'pages','action'=>'display', 'upload'));

thats what i added to the pages_controller:

//uploader plugin
var $components = array('Uploader.Uploader');
var $actsAs = array('Uploader.FileValidation');

function upload() {
//http://www.milesj.me/resources/script/uploader-plugin
$this->set('testvar', "hello world");
$this->Uploader->uploadDir = 'files/uploads/';
$this->Uploader->enableUpload = true;
$this->Uploader->maxFileSize = '8M'; // 8 Megabytes
$this->Uploader->maxNameLength = 40;
//$this->Uploader->mime('image', 'gif', 'image/gif');
//$this->Uploader->delete('files/uploads/filename.jpg');

if (!empty($this->data)) {
if ($data = $this->Uploader->upload('fileName', 
array('overwrite' =>
true, 'name' => 'new_fileName'))){
debug($data);
}
}
}


when i now want to upload a file, i get always the error:
Error: ModelsController could not be found.

thank you very much in advance for any help

regards from spain, martin

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Help - HABTM Multi-Select Field

2011-02-24 Thread Mr.Jayesh
Hi everyone,

I am working on a project where I have set up a habtm for Categories.
I am using CakePHP 1.3
The issue I am stuck is as under:

I have a post form, where I have a Milti Select box for categories, so
I can select all the categories that the post belongs to and post it.
It works fine and all the relevant entries goes to the correct tables
(posts, categories, categories_posts).

I am using Tree structure, so I have lft and rght set in the
categories table.

I have two types forms field in different forms which is to be
populated by $categories:
1. Dropdown - for creating new categories in system.
2. Multi-Select - for posts

and code of $controllers that I used is:

Dropdown: $this->Category->generatetreelist (null, '{n}.Category.id',
'{n}.Category.cat_name', '...');
This works fine and list is seem to be in hierarchy

But problem is when I use similar code of Posts form, the category
list is just in plain list without hierarchy. Code used for that is:

$categories = $this->Post->Category->generatetreelist (null,
'{n}.Category.id', '{n}.Category.cat_name', '...');

And in view:
echo $this->Form->input('Category.Category', array('label' =>
'Categories:', 'options' => $categories));

I want to get an hierarchical list of categories in the multi-select
field as set up in database. I tried many ways but no result.
Please advice.

Regards,
Thanks.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: DEBUG=2: My error500 shows; DEBUG=0: I get "not found". --psybear

2011-02-24 Thread Joshua Muheim
According to the following article, this seems to be the normal CakePHP-way.

http://nuts-and-bolts-of-cakephp.com/2008/08/29/dealing-with-errors-in-cakephp/

So, errors are only displayed to the programmer while developing, and
not to the user while surfing. If you want to display something
different to the default 404 when an error happens, you should call
$this->render('some_error') or something like that.

On Wed, Jan 26, 2011 at 9:44 AM, Joshua Muheim  wrote:
> Thanks for your reply, Steve. I have created app/app_controller.php
> with the following content:
>
>  class AppError extends ErrorHandler {
>  function error500($params) {
>    header('HTTP/1.1 500 Internal Server Error');
>    $this->_outputMessage('error500');
>  }
> }
> ?>
>
> But it still doesn't work, although the AppError handler is taken into
> account: when placing a die("hello"); into the error500() method, then
> having DEBUG set to 2 displays "hello", but DEBUG set to 0 displays
> the old "Not found" error message... What am I missing?
>
> On Tue, Jan 25, 2011 at 5:50 PM, Steve  wrote:
>> I think you need to provide a appError class. The default code turns off
>> the error routing when you disable DEBUG ( set it to 0 ) so it looks for
>> a URL which your server is correctly reporting the absence of.
>>
>> http://book.cakephp.org/view/154/Error-Handling
>>
>>
>> On Tue, 2011-01-25 at 08:21 -0800, psybear83 wrote:
>>> Hey everybody
>>>
>>> When having DEBUG set to 2 (or 1), my sweet little error500 is shown
>>> correctly.
>>>
>>> SomeController extends AppController {
>>>       function _error500() {
>>>         $this->cakeError('error500');
>>>         exit;
>>>       }
>>> }
>>>
>>> But when it's set to 0, then I'm just getting a plain "Error: The
>>> requested address 'xxx' was not found on this server."
>>>
>>> Any idea what's going (wr)on(g)? Please give me a hint - as soon as
>>> this is working my website is ready for being released in beta-
>>> testing. :-)
>>>
>>> Thanks
>>> Josh
>>>
>>
>>
>> --
>> Our newest site for the community: CakePHP Video Tutorials 
>> http://tv.cakephp.org
>> Check out the new CakePHP Questions site http://ask.cakephp.org and help 
>> others with their CakePHP related questions.
>>
>>
>> To unsubscribe from this group, send email to
>> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
>> http://groups.google.com/group/cake-php
>>
>

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


model relation problem

2011-02-24 Thread pang
I have a Model User, and another Model Friend. in the Friend Model, I
have 2 foreign keys user_id and friend_id, both points to the same
User Model.  in this design, all the operations on Friend Model
doesn't work, find, delete.

The error is like this:

SQL Error: 1066: Not unique table/alias: 'Friend'

Query: SELECT `Friend`.`user_id`, `Friend`.`friend_id`, `Friend`.`id`
FROM `friends` AS `Friend` LEFT JOIN `users` AS `User` ON
(`Friend`.`user_id` = `User`.`id`) LEFT JOIN `friends` AS `Friend` ON
(`Friend`.`friend_id` = `Friend`.`id`)  WHERE `Friend`.`id` = 9
LIMIT 1

The  problem is `Friend`.`friend_id` is left joined with
`Friend`.`id`. How to solve this problem ?

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Have my own Controller::var variable that is not overridden by descending AnotherController::var (but merged)? --psybear

2011-02-24 Thread Joshua Muheim
I have created a class that components can descend which provides this
functionality.

http://svn3.xp-dev.com/svn/cakephp/libs/magic_tools/libs/magic_component.php

MagicComponent offers you this functionality by letting you specify
which attributes you want to merge in your AppController and
descending controllers using the MagicComponent::$attributesToMerge
attribute:

MyComponent extends MagicComponent {
  var $attributesToMerge = array('someVar');
}

Now your AppController::$someVar and descending controller's $someVar
attribute automatically get merged (they both need to be an array, of
course):

AppController extends Controller {
  var $someVar = array('one', 'two');
}

SomeController extends AppController {
  var $someVar = array('three');
}

For SomeController, MagicComponent will now automatically set $someVar
to the value `array('one', 'two', 'three')` - as you know it already
from some other variables like AppController::$uses or
AppController::$helpers.

Notice: I think I read somewhere that components should inherit from
Object because otherwise it could lead to infinite loops or something
like that. I didn't experience this problem so far, but be warned!

On Thu, Dec 2, 2010 at 12:47 PM, Joshua Muheim  wrote:
> Thanks for pointing me into the right direction! :-)
>
> On Thu, Dec 2, 2010 at 11:56 AM, Amit Badkas  wrote:
>> Hi,
>> Controller does merging of 'uses', 'helpers' and 'components' only by
>> default, please have a look at __mergeVars() method in
>> cake/libs/controller/controller.php
>> Amit Badkas
>> PHP Applications for E-Biz: http://www.sanisoft.com
>>
>>
>> On Thu, Dec 2, 2010 at 3:53 PM, psybear83  wrote:
>>>
>>> Hey everybody
>>>
>>> I know that CakePHP applies some magic to inheritance. So when having
>>> a class...
>>>
>>> class AppController extends Controller {
>>>  var $uses = array('Model', 'AnotherModel');
>>> }
>>>
>>> ...and then extending another one from it...
>>>
>>> class AnotherController extends AppController {
>>>  var $uses = array('YetAnotherModel');
>>> }
>>>
>>> ...we don't end up with AnotherController::uses being...
>>>
>>> array('YetAnotherModel')
>>>
>>> ...(as PHP would normally do it), but with
>>>
>>> array('Model', 'AnotherModel', 'YetAnotherModel')
>>>
>>> This is very nice! But I wonder how I can use this magic for my own
>>> class variables? E.g. I want AppController::filters to be
>>> array('Filter1', 'Filter2') and then for UsersController I want to add
>>> 'Filter3', then normally I would have to use the beforeFilter:
>>>
>>> UsersController extends AppController {
>>>  function beforeFilter() {
>>>    $this->filters[] = 'Filter3';
>>>  }
>>> }
>>>
>>> But this isn't very beautiful, so I'd rather use the CakePHP magic
>>> mentioned above. But how could I do this? Is there an easy way to tell
>>> CakePHP to treat "filters" the same way as "uses" etc.?
>>>
>>> Thanks a lot 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+unsubscr...@googlegroups.com For more options, visit this group
>>> at http://groups.google.com/group/cake-php?hl=en
>>
>> Check out the new CakePHP Questions site http://cakeqs.org and help others
>> with their CakePHP related questions.
>>
>> You received this message because you are subscribed to the Google Groups
>> "CakePHP" group.
>> To post to this group, send email to cake-php@googlegroups.com
>> To unsubscribe from this group, send email to
>> cake-php+unsubscr...@googlegroups.com For more options, visit this group at
>> http://groups.google.com/group/cake-php?hl=en
>>
>

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Is there a standard way of making sure that foreign keys exist?

2011-02-24 Thread Joshua Muheim
Oops, my bad, wrong behavior (although the mentioned one is quite
useful, too). Here's the correct one:

Automatically verify foreign keys in CakePHP: http://josh.ch/wordpress/?p=63

On Thu, Feb 24, 2011 at 5:33 PM, Joshua Muheim  wrote:
> I have added this behavior to my Subversion repository and created a
> small blog article about it... I hope someone finds this useful.
>
> Automatically prevent records with depending children from being deleted:
> http://josh.ch/wordpress/?p=80
>
> On Fri, Nov 5, 2010 at 9:46 AM, Joshua Muheim  wrote:
>> It's done. :-)
>>
>> > /**
>>  * ???
>>  */
>> class ForeignKeyVerifiableBehavior extends ModelBehavior {
>>  function setup(&$Model, $settings) {
>>    $Model->orphansProtectableOptions = array_merge(array(
>>    ), $settings);
>>  }
>>
>>  /**
>>   * ???
>>   */
>>  function beforeValidate(&$Model) {
>>    $valid = true;
>>    foreach($Model->belongsTo as $model => $settings) {
>>      $foreignKey = $settings['foreignKey'];
>>      $foreignKeyValue = $Model->data[$Model->name][$foreignKey];
>>      if(!empty($foreignKeyValue)) {
>>        $Model->{$model}->id = $foreignKeyValue;
>>        if(!$Model->{$model}->exists()) {
>>          $Model->invalidate($foreignKey, sprintf(__('ID %s does not
>> exist', true), $foreignKeyValue));
>>          $valid = false;
>>        }
>>      }
>>    }
>>    return $valid;
>>  }
>> }
>> ?>
>>
>> Maybe I will upload this to my SVN and add a blog post for it, soon...
>>
>> On Thu, Nov 4, 2010 at 9:51 PM, cricket  wrote:
>>> On Thu, Nov 4, 2010 at 5:57 AM, psybear83  wrote:
 Hi everybody

 Before creating a behavior myself I wanted to ask this (see title).

 I only found this:
 http://ask.cakephp.org/questions/view/how_to_check_the_validness_of_a_foreign-key_must_contained_in_primary-key_list

 ...but there's no solution for the problem.

 If nothing like this exists yet, I will create a behavior on my own
 and will be happy to share it with the community. Just don't want to
 do work that's already been done.
>>>
>>> It should be straightforward to create a custom validation method.I've
>>> never considered using a behavior for validation but I think it could
>>> be done in principle.
>>>
>>> Check out the new CakePHP Questions site http://cakeqs.org and help others 
>>> with their CakePHP related questions.
>>>
>>> You received this message because you are subscribed to the Google Groups 
>>> "CakePHP" group.
>>> To post to this group, send email to cake-php@googlegroups.com
>>> To unsubscribe from this group, send email to
>>> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
>>> http://groups.google.com/group/cake-php?hl=en
>>>
>>
>

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Is there a standard way of making sure that foreign keys exist?

2011-02-24 Thread Joshua Muheim
I have added this behavior to my Subversion repository and created a
small blog article about it... I hope someone finds this useful.

Automatically prevent records with depending children from being deleted:
http://josh.ch/wordpress/?p=80

On Fri, Nov 5, 2010 at 9:46 AM, Joshua Muheim  wrote:
> It's done. :-)
>
>  /**
>  * ???
>  */
> class ForeignKeyVerifiableBehavior extends ModelBehavior {
>  function setup(&$Model, $settings) {
>    $Model->orphansProtectableOptions = array_merge(array(
>    ), $settings);
>  }
>
>  /**
>   * ???
>   */
>  function beforeValidate(&$Model) {
>    $valid = true;
>    foreach($Model->belongsTo as $model => $settings) {
>      $foreignKey = $settings['foreignKey'];
>      $foreignKeyValue = $Model->data[$Model->name][$foreignKey];
>      if(!empty($foreignKeyValue)) {
>        $Model->{$model}->id = $foreignKeyValue;
>        if(!$Model->{$model}->exists()) {
>          $Model->invalidate($foreignKey, sprintf(__('ID %s does not
> exist', true), $foreignKeyValue));
>          $valid = false;
>        }
>      }
>    }
>    return $valid;
>  }
> }
> ?>
>
> Maybe I will upload this to my SVN and add a blog post for it, soon...
>
> On Thu, Nov 4, 2010 at 9:51 PM, cricket  wrote:
>> On Thu, Nov 4, 2010 at 5:57 AM, psybear83  wrote:
>>> Hi everybody
>>>
>>> Before creating a behavior myself I wanted to ask this (see title).
>>>
>>> I only found this:
>>> http://ask.cakephp.org/questions/view/how_to_check_the_validness_of_a_foreign-key_must_contained_in_primary-key_list
>>>
>>> ...but there's no solution for the problem.
>>>
>>> If nothing like this exists yet, I will create a behavior on my own
>>> and will be happy to share it with the community. Just don't want to
>>> do work that's already been done.
>>
>> It should be straightforward to create a custom validation method.I've
>> never considered using a behavior for validation but I think it could
>> be done in principle.
>>
>> Check out the new CakePHP Questions site http://cakeqs.org and help others 
>> with their CakePHP related questions.
>>
>> You received this message because you are subscribed to the Google Groups 
>> "CakePHP" group.
>> To post to this group, send email to cake-php@googlegroups.com
>> To unsubscribe from this group, send email to
>> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
>> http://groups.google.com/group/cake-php?hl=en
>>
>

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Easiest way to get data from a model (better way than $model->data['modelname']['field'])?

2011-02-24 Thread Joshua Muheim
Just in case somebody is interested... I have added a small method
data() that works a little nicer in my opinion than the standard way
of accessing the data array's values is...

So instead of $this->Model->data['User']['name'] you can just call
$this->Model->data('name')... saves you a few keystrokes. Most of you
guys will say this is not necessary... ;-) And maybe you're right. But
here it goes...

  // Put this into your AppModel
  /**
   * Makes returning model data convenient.
   *
   * Examples:
   * - data('name') returns $model->data[]['name']
   * - data('Group') returns $model->data['Group']
   * - data('Groups') returns $model->data['Groups']
   * - data('Group', 'id') returns $model->data['Group']['id']
   *
   * @param $model Model
   * @return mixed
   */
  function data(&$model) {
$association = null;
$field = null;

$params = func_get_args();
array_shift($params); // Remove the pointer to the model (first argument)

$paramsCount = count($params);
$association = null;
$field = null;
if($paramsCount == 2) {
  $association = $params[0];
  $field = $params[1];
} elseif($paramsCount == 1) {
  if(ctype_upper($params[0][0])) {
$association = $params[0];
  } else {
$association = $model->name;
$field = $params[0];
  }
}

if(isset($model->data[$association])) {
  if(!empty($field)) {
if(isset($model->data[$association][$field])) {
  return $model->data[$association][$field];
}
  } else {
if(isset($model->data[$association])) {
  return $model->data[$association];
}
  }
}

return false;
  }

On Wed, Oct 20, 2010 at 1:14 AM, cricket  wrote:
> On Tue, Oct 19, 2010 at 7:03 PM, cricket  wrote:
>> On Tue, Oct 19, 2010 at 5:53 AM, psybear83  wrote:
>>> Hi everybody
>>>
>>> Sorry for this newbish question, but I don't seem to find much about
>>> this (although I should, I guess).
>>>
>>> $m = $this->Model->find(1);
>>
>> Since when does find() work like that? What version are you using?
>>
>>> echo $m->data['Model']['something];
>>
>> How are you getting an object returned from find()? Did I miss something?
>>
>
> Whoops! Please disregard. I didn't understand that you were
> *suggesting* it be done this way.
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en
>

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Is there an easy way to tell CakePHP to use another db setting instead of $default?

2011-02-24 Thread Joshua Muheim
Inspired by Euromark's article
(http://www.dereuromark.de/2010/08/17/development-vs-productive-setup/),
I managed to achieve this functionality in my WebTestsWithFixtures
library. So if anyone needs more inspiration, look at the file
database_config_for_web_tests_with_fixtures.php in this library, maybe
it's of use to someone. In my case, the database connection is
established depending on whether a special header is sent by the
browser or not. This way, whenever this special header is sent,
CakePHP connects to the test database (because only web tests send
this header), and elseway it connects to the "normal" database.

I've written more about the library in my blog:

- Why web tests using the development database are a bad thing:
http://josh.ch/wordpress/?p=8
- Finally: use fixtures with your CakePHP web tests!:
http://josh.ch/wordpress/?p=71

I hope somebody else will find this useful. :-) Please leave a message
if you try it... I'm happy to optimize it further.

On Mon, Oct 18, 2010 at 9:43 AM, Joshua Muheim  wrote:
> Thanks, guys! I will take a look at these links.
>
> On Fri, Oct 15, 2010 at 1:28 PM, euromark  wrote:
>> this is nothing compared to not using lazyloading on models
>> like 0.001% :)
>> so I wouldn't bother
>>
>> i am sure it can be slightly optimized (caching?), though.
>>
>>
>> On 15 Okt., 13:02, Jeremy Burns | Class Outfit
>>  wrote:
>>> I have thought of doing something like before, but I can't help thinking 
>>> that adding in a 'check which environment this is and change some settings' 
>>> process is a tiny yet present overhead in the production instance. Maybe 
>>> I'm just a coding skin flint ;-)
>>>
>>> Jeremy Burns
>>> Class Outfit
>>>
>>> jeremybu...@classoutfit.comhttp://www.classoutfit.com
>>>
>>> On 15 Oct 2010, at 11:58, euromark wrote:
>>>
>>>
>>>
>>> > you may also setup something like this
>>> >http://www.dereuromark.de/2010/08/17/development-vs-productive-setup/
>>> > it will automatically switch to the setting of the current environment
>>>
>>> > On 15 Okt., 11:19, Jeremy Burns | Class Outfit
>>> >  wrote:
>>> >> From the 1.3 
>>> >> guide:http://book.cakephp.org/view/922/Database-Configuration
>>>
>>> >> Jeremy Burns
>>> >> Class Outfit
>>>
>>> >> jeremybu...@classoutfit.comhttp://www.classoutfit.com
>>>
>>> >> On 15 Oct 2010, at 10:04, MissYeh wrote:
>>>
>>> >>> You can do that by setting the dbconfig in a specific model that needs
>>> >>> another db using the var $useDbConfig
>>>
>>> >>> See for more infohttp://book.cakephp.org/view/310/Configuration
>>>
>>> >>> Or here is an article about changing database configuration on the
>>> >>> fly:
>>> >>>http://insanityville.com/2010/04/how-to-switch-between-databases-in-c...
>>>
>>> >>> Hope this helps!
>>>
>>> >>> Kana
>>>
>>> >>> On Oct 15, 9:49 am, psybear83  wrote:
>>>  Hi everybody
>>>
>>>  Is there an easy way to tell CakePHP to use another db setting instead
>>>  of $default? Maybe something like
>>>
>>>  Configure::write('please.let.me.use.this.database', 'test');
>>>
>>>  Thanks a lot
>>>  Josh
>>>
>>> >>> Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp others 
>>> >>> with their CakePHP related questions.
>>>
>>> >>> You received this message because you are subscribed to the Google 
>>> >>> Groups "CakePHP" group.
>>> >>> To post to this group, send email to cake-php@googlegroups.com
>>> >>> To unsubscribe from this group, send email to
>>> >>> cake-php+unsubscr...@googlegroups.com For more options, visit this 
>>> >>> group athttp://groups.google.com/group/cake-php?hl=en
>>>
>>> > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others 
>>> > with their CakePHP related questions.
>>>
>>> > You received this message because you are subscribed to the Google Groups 
>>> > "CakePHP" group.
>>> > To post to this group, send email to cake-php@googlegroups.com
>>> > To unsubscribe from this group, send email to
>>> > cake-php+unsubscr...@googlegroups.com For more options, visit this group 
>>> > athttp://groups.google.com/group/cake-php?hl=en
>>
>> Check out the new CakePHP Questions site http://cakeqs.org and help others 
>> with their CakePHP related questions.
>>
>> You received this message because you are subscribed to the Google Groups 
>> "CakePHP" group.
>> To post to this group, send email to cake-php@googlegroups.com
>> To unsubscribe from this group, send email to
>> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
>> http://groups.google.com/group/cake-php?hl=en
>>
>

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: So IS there a way to use fixtures with web tests or NOT???

2011-02-24 Thread Joshua Muheim
(Hey everybody. I'm just looking through my old posts here in the
CakePHP user group and try to give useful answers for those I managed
to answer myself in the meantime, hoping somebody else will find it
useful, too. So please don't blame me for maybe posting the same
answer to different questions (they often result in the same answer),
I don't want to spam, I just want to help. Redundant information can't
be wrong, I guess, and somebody googling for something might find only
one of the many posts. So here we go again...)

I managed to work out a solution for this, and I released it as a
library so everyone can use it. I've written in my blog about it.

- Why web tests using the development database are a bad thing:
http://josh.ch/wordpress/?p=8
- Finally: use fixtures with your CakePHP web tests!:
http://josh.ch/wordpress/?p=71

I hope somebody else will find this useful. :-) Please leave a message
if you try it... I'm happy to optimize it further.

On Fri, Sep 17, 2010 at 11:52 AM, Joshua Muheim  wrote:
> Your link looks very interesting. I will take a look at it. Thanks!
>
> On Thu, Sep 16, 2010 at 10:10 PM, euromark  wrote:
>> there are many solutions for one database.php for all environments
>>
>> this is one possibility:
>> http://www.dereuromark.de/2010/08/17/development-vs-productive-setup/
>>
>> no matter where it is, it will select the appropriate setting
>>
>> for your test cases you need to modiy the constructor though
>> i use the same config as default, but with another prefix
>> maybe you should set up a new database for it (if you want)
>>
>>
>> On 16 Sep., 10:35, Joshua Muheim  wrote:
>>> Thanks, Nick.
>>>
>>> > You're welcome.  What you're running into is a limitation of the
>>> > Testing Framework CakePHP 1.x decided to use -- SimpleTest.  CakePHP
>>> > 2.0 will be using the PHP defacto standard PHPUnit as their testing
>>> > framework from now on.
>>>
>>> Will PHPUnit allow web testing, too?
>>>
>>> > PHPUnit is more in line of what a similar RoR test framework will give
>>> > you.  RoR is a great framework, I actually came to CakePHP from a
>>> > heavy Ruby on Rails background.   I have my personal gripes with RoR,
>>> > but that's nothing new, nothing is perfect.  However the issue with
>>> > webtesting will persist through even in Ruby on Rails.  This is
>>> > because the idea of web testing testing your app from point to point
>>> > (from a browser), fixture's don't really make sense in that scope.
>>>
>>> Yes it does make sense IMO. E.g. when testing CRUD of a model that
>>> depends on other model data (e.g. one has to be able to pick a
>>> "Publisher" from a selection list to create a new "Book") this makes
>>> perfect sense instead of first creating all the needed model data in
>>> the first place (which is what I'm doing at the moment in my CakePHP
>>> web tests).
>>>
>>> > Sure you can do things like seed data and rake is a great tool for
>>> > doing just that but you'd be doing the same thing you'd be doing to
>>> > get it working in CakePHP spoofing your app to run on a test
>>> > database rather than production based on some request.
>>>
>>> Yes, but the difference is that RoR has already implemented this (IMO
>>> *very* self-evident feature) whereas CakePHP doesn't.
>>>
>>> > WebTesting in RubyOnRails is often done with Selenium (http://
>>> > seleniumhq.org/).  You can install a really cool Firefox plugin that
>>> > will actually write your testcase for you as you click, edit forms,
>>> > etc...  With PHPUnit (CakePHP 2.0) You'll be able to do the same thing
>>> > with their Selenium extention (http://www.phpunit.de/manual/3.1/en/
>>> > selenium.html)
>>>
>>> I have worked with Selenium IDE already. It's cool, but what does this
>>> have to do with the actual topic here? :-)
>>>
>>> > I'm not trying to discourage you from picking up Ruby on Rails, just
>>> > stating your "problem" will persist regardless as the issue is
>>> > conceptual more than actual.
>>>
>>> I just don't get why this is such a big thing? Give me two things in 
>>> CakePHP:
>>> - Fixtures in web tests
>>> - A test-DB in web tests
>>> ...and I am happy. This can't be a big deal, can it?
>>>
>>> Thanks for another very informative reply,
>>> Josh
>>>
>>>
>>>
>>> > Hope that helps,
>>> > Nick
>>>
>>> > On Sep 16, 12:57 am, Joshua Muheim  wrote:
>>> >> WOW, thank you so much for your very informative answer, Nick! I
>>> >> nearly gave up all hope already.
>>>
>>> >> I absolutely agree with everything you write. I just don't understand
>>> >> why the CakePHP developers don't seem to see it "our" way? Why didn't
>>> >> they tweak SimpleTest so it fits our need with the separate
>>> >> staging-database? I really am no very experienced PHP programmer, and
>>> >> I guess it would take me quite a long time to do the modifications you
>>> >> suggested... and it would be quite buggy, too.
>>>
>>> >> Well, in a few days I will have a talk to my boss and I will suggest
>>> >> him to switch from CakePHP to Ruby On

Re: Web tests using fixtures: Finally got them working!

2011-02-24 Thread Joshua Muheim
I have updated my solution, it's available as a library now that can
be used without big hassles. See here...

- Why web tests using the development database are a bad thing:
http://josh.ch/wordpress/?p=8
- Finally: use fixtures with your CakePHP web tests!:
http://josh.ch/wordpress/?p=71

I hope somebody else will find this useful. :-) Please leave a message
if you try it... I'm happy to optimize it further.

On Thu, Oct 14, 2010 at 11:28 AM, Joshua Muheim  wrote:
> OK, I slightly updated the post and corrected the download link.
> Please, give it a try! :-)
>
> On Thu, Oct 14, 2010 at 10:31 AM, Joshua Muheim  wrote:
>> Thanks for your reply, David.
>>
>> On Thu, Oct 14, 2010 at 10:30 AM, dtemes  wrote:
>>> Thanks for sharing!
>>>
>>> check the link to the source code, it's not working for me.
>>
>> I'll take a look at it.
>>
>>> I have not
>>> seen the code, but you mention that you have just copy and pasted the
>>> fixtures code into your CakeWebTestCaseWithFixtures class. Instead of
>>> doing that you can instantiate a CakeTestCase inside your class and
>>> create some wrapper methods that call the corresponding methods of the
>>> CakeTestCase instance.
>>
>> Great idea! Thank you.
>>
>

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: hasMany: check for depending objects when deleting and deny?

2011-02-24 Thread Joshua Muheim
I created a behavior that automatically does just this. I wrote about
it in my blog:

Automatically prevent records with depending children from being
deleted: http://josh.ch/wordpress/?p=80

I hope somebody will this useful. Please comment on it, I'm happy to
optimize it if needed. :-)

On Tue, Oct 19, 2010 at 4:15 PM, Joshua Muheim  wrote:
> So it seems there's no such functionality yet? I will try to create a
> component or something for this...
>
> On Thu, Sep 16, 2010 at 12:17 PM, Jeremy Burns | Class Outfit
>  wrote:
>> Go directly to the source; use referential integrity in InnoDB.
>>
>> Jeremy Burns
>> Class Outfit
>>
>> jeremybu...@classoutfit.com
>> http://www.classoutfit.com
>>
>> On 16 Sep 2010, at 11:12, psybear83 wrote:
>>
>>> Hi all
>>>
>>> I know that I can use the dependent flag to automatically delete all
>>> the associated model objects.
>>>
>>> But I'd rather have an option to prevent deletion of the object as
>>> long as it's having other depending objects. Is there an easy way to
>>> do this?
>>>
>>> Thanks a lot
>>> 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+unsubscr...@googlegroups.com For more options, visit this group at 
>>> http://groups.google.com/group/cake-php?hl=en
>>
>> Check out the new CakePHP Questions site http://cakeqs.org and help others 
>> with their CakePHP related questions.
>>
>> You received this message because you are subscribed to the Google Groups 
>> "CakePHP" group.
>> To post to this group, send email to cake-php@googlegroups.com
>> To unsubscribe from this group, send email to
>> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
>> http://groups.google.com/group/cake-php?hl=en
>>
>

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Connect to test-DB when running web tests?

2011-02-24 Thread Joshua Muheim
I managed to work out a solution for this, and I released it as a
library so everyone can use it. I've written in my blog about it.

- Why web tests using the development database are a bad thing:
http://josh.ch/wordpress/?p=8
- Finally: use fixtures with your CakePHP web tests!:
http://josh.ch/wordpress/?p=71

I hope somebody else will find this useful. :-) Please leave a message
if you try it... I'm happy to optimize it further.

On Tue, Sep 7, 2010 at 9:10 AM, psybear83  wrote:
> Hi all
>
> I'd like my CakePHP app to connect to its test-DB when I run my web
> tests (CakeWebTestCase). How is this possible? As far as I understand
> CakePHP only connects to the test-DB when running the unit tests, is
> this true? This wouldn't really make much sense to me...
>
> Thanks for information,
> 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+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en
>

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Webtesting using SimpleTest: How to reset database?

2011-02-24 Thread Joshua Muheim
I managed to work out a solution for this, and I released it as a
library so everyone can use it. I've written in my blog about it.

- Why web tests using the development database are a bad thing:
http://josh.ch/wordpress/?p=8
- Finally: use fixtures with your CakePHP web tests!:
http://josh.ch/wordpress/?p=71

I hope somebody else will find this useful. :-) Please leave a message
if you try it... I'm happy to optimize it further.

On Mon, Sep 6, 2010 at 2:30 PM, Joshua Muheim  wrote:
> Thank you, but this looks like an article that only tells how to use
> fixtures with unit (model) tests. I need this kind of stuff for web
> (view) tests...
>

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Conneect with Oracle

2011-02-24 Thread Nguyễn Trịnh Hồng Ngọc
thanks so much ^^
I have check it and I can connect to oracle database ^^

I use configuration like this:
'driver' => 'oracle',
'connect'=>'oci_connect',
'persistent' => false,
'host' => 'localhost',
'port'=>1521,
'login' => 'hr',
'password' => 'hr',
'database' => 'xe',
'prefix' => '',

and check php_oci8 in PHP-> PHP extensions

Thank you again ^^


On 22 Tháng Hai, 23:04, Zaky Katalan-Ezra  wrote:
> Linux? windows?
> Do you see OCI in phpinfo()?

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Making form widgets in cakephp

2011-02-24 Thread Jeremy Burns | Class Outfit
What version of Cake are you using? Some of your syntax seems a little old. 
Normally you would do this:

element('elementName'); ?> rather than renderElement (which I 
*think* is from an earlier version?).

You can echo out the flash message:

Session->flash(); ?>

Note that I am using an upper case S in Session, which is the accepted way in 
version 1.3.

What error are you getting when you code your way, and do they improve when you 
make the changes above?

Jeremy Burns
Class Outfit

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

On 24 Feb 2011, at 13:51, jeet bajaj wrote:

> Hello There,
> 
> I have just passed 6 months in cakephp and i am aware of basic
> functioning in cakephp. Now i am trying to make reusable form widgets,
> which can be put anywhere in the site without considering what
> controller and action governs the page, in which that form is
> inserted. For this i decided to make forms in elements folder. for
> example i made login form in element folder as "login.ctp", and put
> the code renderElement("login"); ?> in views/
> cmscontents/index.ctp file, now i want to put multiple autonomous
> forms widgets in same page, in which no one should any how effect the
> other one.
> i got a little bit success in beginning but in further steps i became
> confused. As in login form i  made a login form
> and post it to users/login action in users controller, but in next
> step if the user not found i had to send failure result inside the
> same login widgets above the form fields, i want to use > flash(); ?> for this, but as far as i  know i can't put  $session->flash(); ?> in elements, hence i am confused how to control
> all this.
> So i need help, how to make independent form widgets in elements
> folders, or at least how to handle this issue
> 
> 
> Thanks :-)
> 
> -- 
> Our newest site for the community: CakePHP Video Tutorials 
> http://tv.cakephp.org 
> Check out the new CakePHP Questions site http://ask.cakephp.org and help 
> others with their CakePHP related questions.
> 
> 
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Making form widgets in cakephp

2011-02-24 Thread jeet bajaj
Hello There,

I have just passed 6 months in cakephp and i am aware of basic
functioning in cakephp. Now i am trying to make reusable form widgets,
which can be put anywhere in the site without considering what
controller and action governs the page, in which that form is
inserted. For this i decided to make forms in elements folder. for
example i made login form in element folder as "login.ctp", and put
the code renderElement("login"); ?> in views/
cmscontents/index.ctp file, now i want to put multiple autonomous
forms widgets in same page, in which no one should any how effect the
other one.
i got a little bit success in beginning but in further steps i became
confused. As in login form i  made a login form
and post it to users/login action in users controller, but in next
step if the user not found i had to send failure result inside the
same login widgets above the form fields, i want to use flash(); ?> for this, but as far as i  know i can't put flash(); ?> in elements, hence i am confused how to control
all this.
So i need help, how to make independent form widgets in elements
folders, or at least how to handle this issue


Thanks :-)

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Folders inside img/

2011-02-24 Thread Aleksandr (cligs.ee)
I created a folder cropped_images inside img folder and uploaded my
photos there. But when I try to open them in the browser, Apache
decides to tunnel the request through cake instead of serving static
files, which gives me a warning that I'm missing ImgController.

How can I fix it?

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: cakephp Messaging sysytem

2011-02-24 Thread Ma'moon
i just have 2 points to mention for this subject:

1) If you are going to use an RDBMS to store the messages using MySQL then
use `InnoDB` as your table engine instead of `MyISAM`
2) This kind of tables by nature grows faster than the most of the other
tables in terms of records in your system, and hence you will reach a
scalability and performance issues once this table goes for large amount of
data, hence i would recommend considering IMAP for such a task.

i have worked on such an environments before with very high traffic and very
large amount of data and after pulling our hairs off to boost the
performance we saw that IMAP was the best solution ever for this kind of
tasks

Ma'moon

On Wed, Feb 23, 2011 at 8:08 PM, euromark wrote:

> sure
>
> CREATE TABLE IF NOT EXISTS `comm_conversations` (
>  `id` char(36) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
>  `user_id` char(36) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
>  `title` varchar(60) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
>  `created` datetime NOT NULL,
>  `last_message_id` int(10) unsigned NOT NULL DEFAULT '0',
>  `allow_add` tinyint(1) unsigned NOT NULL DEFAULT '0',
>  `count` int(10) unsigned NOT NULL DEFAULT '0',
>  PRIMARY KEY (`id`),
>  KEY `user_id` (`user_id`)
> ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
>
> CREATE TABLE IF NOT EXISTS `comm_conversation_messages` (
>  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
>  `conversation_id` char(36) COLLATE utf8_unicode_ci NOT NULL,
>  `user_id` char(36) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
>  `attachment_id` int(10) unsigned NOT NULL DEFAULT '0',
>  `message` text COLLATE utf8_unicode_ci NOT NULL,
>  `created` datetime NOT NULL,
>  PRIMARY KEY (`id`),
>  KEY `user_id` (`user_id`)
> ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
> AUTO_INCREMENT=109 ;
>
> CREATE TABLE IF NOT EXISTS `comm_conversation_users` (
>  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
>  `conversation_id` char(36) COLLATE utf8_unicode_ci NOT NULL,
>  `user_id` char(36) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
>  `status` tinyint(2) unsigned NOT NULL DEFAULT '0' COMMENT '0=ok,
> 1=deleted,2=removed',
>  `last_view` int(10) unsigned NOT NULL DEFAULT '0',
>  `created` datetime NOT NULL,
>  PRIMARY KEY (`id`),
>  KEY `user_id` (`user_id`),
>  KEY `conversation_id` (`conversation_id`)
> ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
> AUTO_INCREMENT=110 ;
>
>
>
>
>
> On 23 Feb., 21:31, Josh  wrote:
> > Hey euromark,
> >
> > That looks like exactly what I'm trying to do.  Could you also let us
> know
> > what columns are in each table?  I'm sort of following your logic, but
> not
> > 100% and I think seeing the table columns would help a lot.
> >
> > ~Josh
>
> --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group
> at http://groups.google.com/group/cake-php
>

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: cakephp Messaging sysytem

2011-02-24 Thread Stephen
I have a simplified messaging system.

User
Message
MessageRecipient
MessageSender

doesn't support composing to multiple users or threaded conversations, works
fine as a simple system.

On 24 February 2011 01:26, Josh  wrote:

> So to generate a user's "inbox", I'm guessing you would select all of the
> conversation_id's from the conversation_users table and save them to an
> array.  Then you would select the messages from the messages table where the
> conversation_id is in the array you made that contains all of the
> conversation_id's for the current user and where the sender is not the
> current user.  You group by conversation_id and choose the highest
> message.id from the group to be the message to display in the inbox.
>
> At least that's my guess as to how you would do it.  Is there a better way?
>
> --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group
> at http://groups.google.com/group/cake-php
>



-- 
Kind Regards
 Stephen

 http://www.ninjacodermonkey.co.uk

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Model data appears to unset after save, is this correct?

2011-02-24 Thread Greg Skerman
Confirming that $this->data is unset after save... in fact unset after the
AfterSave() callback.

Worked around it by setting the filename to a private property on first
generation of the filename

any insight into why this unsetting goes on? I'm sure there is a good
reason..


On Thu, Feb 24, 2011 at 6:43 PM, Greg Skerman  wrote:

> Hi,
>
> I've been working on a very simple app to upload and resize some images,
> and name the file in accordance with some information that has been provided
> in a form.
>
> To do this, my model has a public method "createFilename", which relies on
> $this->data to build the filename in accordance with the provided business
> rules.
>
> It was all working fine, until I connected the model to a database table
> and started also saving the meta-data now it appears $this->data is
> being unset for subsequent calls to the method.
>
> The method is simple enough:
>
> public function createFilename() {
> CakeLog::write('debug', 'photo name is '. 
> $this->data['Photo']['name']);
> $name = $this->data['Photo']['name'];
> $level = $this->data['Photo']['level'];
> $category = $this->data['Photo']['category'];
> $month = strtoupper($this->data['Photo']['month']);
>
> return $level . $category . $month . $name . '.jpg';
> }
>
> According to the information that I log, in the 4 times this method is
> called during the processing of the image, the first time $this->data[
> 'Photo']['name']  contains data, and then each subsequent call is empty.
>
> The first time the method is called is at validation to prevent duplicate
> files with the same metadata being created, and this seems to be working
> fine, but then the following times (which are used for naming the file after
> it has been manipulated, moving the file out of the TMP directory into the
> uploaded images directory, and including the filename in an email
> attachment, $this->data appears to be empty.
>
> Does the act of saving a record to the database automatically unset the
> $this->data variable or is there something else going on here?
>

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Blog example not working - need edit in View

2011-02-24 Thread Huy Nguyen
I think what dalvarez spotted out is exactly why I got into this problem!

Thank you!

On Mon, Feb 14, 2011 at 5:25 AM, dalvarez  wrote:

>
> I actually ran across the same exact problem. After looking at CakePHP's
> downloads page on Github, I noticed that 1.3-dev.zip was listed higher than
> 1.3.7.zip. I think that the confusion lies in the fact that I (and maybe
> others) mistook this to be a newer version than 1.3.7 and downloaded that
> version instead. I'm downloading the 1.3.7 version now to try it out.
> --
> View this message in context:
> http://cakephp.1045679.n5.nabble.com/Blog-example-not-working-need-edit-in-View-tp3367716p3383722.html
> Sent from the CakePHP mailing list archive at Nabble.com.
>
> --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group
> at http://groups.google.com/group/cake-php
>

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Model data appears to unset after save, is this correct?

2011-02-24 Thread Greg Skerman
Hi,

I've been working on a very simple app to upload and resize some images, and
name the file in accordance with some information that has been provided in
a form.

To do this, my model has a public method "createFilename", which relies on
$this->data to build the filename in accordance with the provided business
rules.

It was all working fine, until I connected the model to a database table and
started also saving the meta-data now it appears $this->data is being
unset for subsequent calls to the method.

The method is simple enough:

public function createFilename() {
CakeLog::write('debug', 'photo name is '. $this->data['Photo']['name']);
$name = $this->data['Photo']['name'];
$level = $this->data['Photo']['level'];
$category = $this->data['Photo']['category'];
$month = strtoupper($this->data['Photo']['month']);

return $level . $category . $month . $name . '.jpg';
}

According to the information that I log, in the 4 times this method is
called during the processing of the image, the first time $this->data[
'Photo']['name']  contains data, and then each subsequent call is empty.

The first time the method is called is at validation to prevent duplicate
files with the same metadata being created, and this seems to be working
fine, but then the following times (which are used for naming the file after
it has been manipulated, moving the file out of the TMP directory into the
uploaded images directory, and including the filename in an email
attachment, $this->data appears to be empty.

Does the act of saving a record to the database automatically unset the
$this->data variable or is there something else going on here?

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Changing Model Conditions in another controller

2011-02-24 Thread heohni
Hi,

I have a Member model with hasMany Subscriptions.

Now, in another controller, I am calling the Member Model to give me
some data.
I want now to create a find() which lists me all active members with
their active subscriptions.

Getting the active Members is easy, as this information is stored
within the members table.
But how can I get now only the  active subscriptions for this
particular member?

When I call $members = $this->Member->find('all');
Cake performs 2 statements.
1. to get all member results
2. to get all subscription results

To get only active members I can set conditions within the find ()
method.
But how can I access the 2. query conditions which is selecting the
subscription results?

Please advise, thanks in advance!

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Numeric vs integer vs digit validation

2011-02-24 Thread Ryan Schmidt

On Feb 14, 2011, at 10:12, John Andersen wrote:

> You always have the opportunity to make your own validation rules, see
> the CakePHP book at:
> http://book.cakephp.org/view/1179/Custom-Validation-Rules
> 
> I don't think the CakePHP team can take into account all the possible
> kinds of validation rules that we would like to have.
> But feel free to make the suggestion to the team for the validation
> rules, that you would like to see in future CakePHP versions.

I know that I can define my own validation rules; I have already done so in my 
project.

I'm not asking for CakePHP to provide all possible validation rules for every 
possible scenario; I'm asking it to provide the most common types of validation 
rules that almost every project will need to use. Integer and especially 
unsigned integer validation are in that category. If I am building a 
ticket-ordering site where I want to know from the user how many tickets they 
want, then I will have an unsigned integer field in my database for that, and I 
will want unsigned integer validation on it. But when I bake this model, 
CakePHP will suggest that I would want "numeric" validation on it. If a user 
enters that they want 3.14 tickets, the numeric validation will allow that 
(which will, when saved into the database, be truncated to 3), whereas I would 
want my model's validation to display an error message to the user instead.

I am a new CakePHP user; the humor of the "female needs help!" thread 
notwithstanding, I find it entirely relevant to mention this, since it means I 
do not know if I am using CakePHP correctly. Bug trackers are great places to 
write up things which are bugs; I was not yet sure whether the behavior I 
observed was a bug or missing feature (though it certainly seemed like it to 
me) or merely me not knowing how it is meant to be used. The reasons I wrote to 
this list were:

 * to verify whether I have understood correctly that CakePHP does not have 
this (to me) basic and fundamental feature built in;
 * to inquire whether anybody else has noticed this before;
 * to express surprise that, when CakePHP is all about tests, this deficiency 
has not been discovered in testing;
 * to gain further input from the community before deciding this is in fact a 
bug that I should write a bug report about





-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php