Can't Save 1 Field

2010-08-06 Thread Dave Maharaj
I am trying to add the viewed by 1 for each view but it will not save.

 

I have:

 

$viewed = $mail['Sendout']['viewed'];



$total = $viewed + "1";

// tried $total = $viewed ++;

// $total = $viewed + '1';

// $total = $viewed + 1;

 

 

 

debug($total); //shows db count plus 1



$this->Sendout->id = $mail['Sendout']['id'];



$this->data['Sendout']['lastview'] = date('Y-m-d H:i:s');// this field saves
the last view timestamp

$this->data['Sendout']['viewed'] = $total; // this never saves db is int(11)



$this->set('sendout', $mail);

 

$this->Sendout->save( $this->data, true );

 

Any ideas where I am going wrong?

 

Thanks

 

 

Dave

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

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


Re: How to allow and deny different actions based on user's role

2010-08-06 Thread Dan Heberden
Just get the role and apply it?

if( $this->Auth->user('User.role') > 1 )  {   // is admin
   $this->Auth->allow( array('secretController' =>
'superSecureAction' ) );
}

On Aug 6, 1:12 pm, "Mariano C."  wrote:
> I have users table, with field id, username, password and role.
> role is a numeric value: 0 banned users, 1 registered users, 2 admins.
>
> I've coded AppController like:
> class AppController extends Controller {
>         var $components = array('Auth');
>
>         function beforeFilter()
>         {
>                 $this->Auth->allow(array('users' => 'register'));
>         }
>
> }
>
> So every user can reach registration page.
> Now I would that for user with different role will be allowed
> different action. How can I handle this just inside the AppController?

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


How to allow and deny different actions based on user's role

2010-08-06 Thread Mariano C.
I have users table, with field id, username, password and role.
role is a numeric value: 0 banned users, 1 registered users, 2 admins.

I've coded AppController like:
class AppController extends Controller {
var $components = array('Auth');

function beforeFilter()
{
$this->Auth->allow(array('users' => 'register'));
}
}

So every user can reach registration page.
Now I would that for user with different role will be allowed
different action. How can I handle this just inside the AppController?

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

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


Re: Full Auth package

2010-08-06 Thread Miles J
Cake only offers the Auth component which does basic logging in/out
and persisting the session.

Everything else like registration, forgot password, reset, etc is up
to the developer to implement according to their needs.

However, you could probably find a user plugin to fit your needs.

Also, I write a remember me feature: http://github.com/milesj/cake-auto_login

On Aug 6, 6:18 am, Konstantin  wrote:
> Hello!
>
> I have started to make my application with Cake, and I wonder:
> is there any component or library with all necessary functions for
> authentication?
> I need login (with "remember me"), logout, register, forgot password,
> profile. I believe it's pretty simple, but I cannot find a complete
> set of functions, only login/logout from tutorial.
>
> Btw, the Bakery is a nightmare, it's impossible to make a good search
> in it. I wanted to filter by Cake version, keywords, categories, but I
> see only a simple search form. If you can suggest a better resource
> for ready-to-use solutions - it will be great.
>
> Thanks!

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

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


Re: how can i tell cake to delete directories automatically after a specific time

2010-08-06 Thread Miles J
Just setup a cron job that runs every 1/24 hour(s) that cleans up the
tmp directory.

Why not just put all uploads into the same tmp directory? Very slim
chance anything will ever overwrite each other.

On Aug 6, 6:03 am, Tomfox Wiranata  wrote:
> hi,
>
> lets say  a user uploads an image. then i create a temp-folder to save
> it temporarily. once the user is finished i delete this temp directory
> and copy the image to the actual path.
>
> now lets say, he uploads it, cake puts it to the temp directory and
> the user cancels the process by shutting down the browser or just
> leaving the website. if that happens, i want to delete the temp-dir.
> so is it possible to check if the user left the site or shut down the
> browser?
>
> if not, then i'd like to check what temp directories have been created
> 24hrs ago and still exist, so i can delete them. is that possible?
>
> thank you so far. as usual :)
>
> btw: i love this forum

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

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


Re: bug with HTML entity encoding of attribute of form elements

2010-08-06 Thread Dan Heberden
As for the quotes thing - i meant sending the slash along with it, so
the rendered, parse, printed, whatever text would _look_ like

onclick="function(\"xxx\");"   more or less a work around

I agree that it needs to be something specific.. I think escape needs
to be mixed - that way it would be backwards compatible..

echo $this->Form->button('', array('onClick' =>
'function(\'xxx
\')', 'escape' => true));

would still work OR

echo $this->Form->button('', array('onClick' =>
'function(\'xxx
\')', 'escape' => array('name') ));

To specify WHAT gets escaped.  - if array, defaults to false for all
others.

Kind of like containable does..




On Aug 6, 4:28 am, drbuzasi  wrote:
> Of course i mean at my first question: ...different options for title/
> selectoptions and for attributes in future versions...
>
> On aug. 6, 13:21, drbuzasi  wrote:
>
>
>
> > I think that's not a problem of php escaping. Using double quotes in
> > javascript isn't a good idea since the code generated (assuming it
> > won't be escaped) would be
> > ... onChange="functon("yyy")"...
> > which is meanless because of the wrapping double quotes.
>
> > IMHO the problem is in form.php and helper.php.
>
> > Button problem:
> > If 'escape' is set true as option in form.php (CakePHP 1.3.3) line
> > 1266 makes title escaped. After then the option remains causing
> > attributes getting escaped as well calling _parseAttributes at line
> > 1271.
> > So title AND attributes will be encoded if 'escape'=>true but none of
> > them while set ti false.
>
> > Select (and $form->input generally) problem:
> > Setting 'escape'=>true HTML encodes only select options because line
> > 1426 saves the value for line 1498 but line 1427 unsets this option.
> > So when calling _parseAttribute at line 1475 this option is not
> > present causing use of default value at line 336 in helper.php.
> > Select attributes will be ALWAYS encoded.
>
> > Question:
> > Should be used different escape options for title/selectoptions in
> > future versions of CakePHP? Or the default value in helper.php line
> > 336 should be set tu false?
>
> > On aug. 6, 06:35, Dan Heberden  wrote:
>
> > > Does changing your quote pattern help?
>
> > > echo $this->Form->select('field', array( '1' => '' , '2' =>
> > > '' ),
> > >                                           null, array('onChange' =>
> > > 'function(\"yyy\")'));
>
> > > \" (because php isn't escaping it) will get sent to the output, which
> > > _should_ render
>
> > > onclick="function(\"yyy\")" -
>
> > > I would do some more tests with sending double quotes vs single quotes
> > > for the ent_quote option of the $form helper..
>
> > > On Aug 5, 5:27 pm, drbuzasi  wrote:
>
> > > > If a button is needed that is labeled as '' and has an
> > > > 'onClick' attribute with some javascript containing a text parameter
> > > > the code can't be created since when 'escape' is set to false in
> > > > options (button default) the script is OK but buttons label will not
> > > > be encoded.
> > > > Setting 'escape' to true HTML encodes my script, too, which is wrong.
>
> > > > echo $this->Form->button('', array('onClick => 'function(\'xxx
> > > > \')'));
> > > > results
> > > > 
>
> > > > echo $this->Form->button('', array('onClick' => 'function(\'xxx
> > > > \')', 'escape' => true));
> > > > results
> > > >  > > > onClick="function('xxx')">

Re: Countries, States and Cities: Which relations i'm dealing with?

2010-08-06 Thread Dan Heberden
you might want to peek into the tree behavior - it makes multi-level
stuff much easier (haven't used the behavior personally, but have used
MPTT quite a bit)

As for your models:

You mentioned your states and countries have the city foreign key,
which I assume is stricly for their capital. This is a belongsTo; when
the key is present in the CURRENT table..

state:
$belongsTo( 'CapitalCity' =>  array( 'className' => 'City'),
   'Country' ); // city_id on state maps to the
capital, country_id maps to the country
$hasMany('City'); // state_id on the cities table map to the current
state (gets all the cities)

country:
$belongsTo('City') // city_id on country maps to capital (gets the
capital city)
$hasMany( 'State') // country_id on the states table maps to the
current country (gets all the states);
(note, if you need the whole chain, you can use containable - it would
let you specify the link such as:
$this->contain('City', 'State' => 'CapitalCity', 'City') // this gets
the countries capital city, states and that states capital and
cities.. cool, eh? )

city:
$belongsTo = array('State') // city has state_id, which gets it's
parent state
( again, you can use containable to get further into state, like get
the state's country and ITs capital, etc etc)

The use of containable is much more flexible than recursive, as it
lets you specify the relationships. 
http://book.cakephp.org/view/1323/Containable
)

hope it helps,
dan


On Aug 5, 8:43 am, DerBjörn  wrote:
> Hi,
>
> i have three tables: countries, states and cities.
>
> Every country has its capital city, so does every state.
> 2 relations are very obvious:
>
> state belongsTo country
> city belongs to state
>
> Now i have a problem to realize the relations referring to the capital
> cities.
> In my opinion there are two hasOne relations:
>
> state hasOne city
> country hasOne city
>
> Both tables (states and countries) has a column names city_id as
> foreign_key, but if i use two hasOnes like
>
> [code]
> var $hasOne = array(
>         'CapitalCity' => array(
>             'className' => 'City',
>             'foreignKey' => 'city_id',
>             'conditions' => '',
>             'fields' => '',
>             'order' => ''
>         )
>     );
> [/code]
>
> i get following error message:
> [quote]Warning (512): SQL Error: 1054: Unknown column
> 'CapitalCity.capitalcity_id' in 'on clause' [CORE/cake/libs/model/
> datasources/dbo_source.php, line 681][/quote]
>
> [quote]Query: SELECT COUNT(*) AS `count` FROM `countries` AS `Country`
> LEFT JOIN `cities` AS `CapitalCity` ON (`CapitalCity`.`city_id` =
> `Country`.`id`) WHERE 1 = 1 [/quote]
>
> Actually it has to be  (`CapitalCity`.`id` = `Country`.`city_id`) to
> make sense. What i did wrong?
> In a forum i asked i ve been told that to realize the capital city
> connections i have to use 2 belongsTo relations, but it doesn't make
> any sense to me.
>
> Somebody can enlight me? :)
> Thanks!

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

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


Full Auth package

2010-08-06 Thread Konstantin
Hello!

I have started to make my application with Cake, and I wonder:
is there any component or library with all necessary functions for
authentication?
I need login (with "remember me"), logout, register, forgot password,
profile. I believe it's pretty simple, but I cannot find a complete
set of functions, only login/logout from tutorial.

Btw, the Bakery is a nightmare, it's impossible to make a good search
in it. I wanted to filter by Cake version, keywords, categories, but I
see only a simple search form. If you can suggest a better resource
for ready-to-use solutions - it will be great.

Thanks!

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

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


Re: Returning Model Instance from a different model

2010-08-06 Thread Andrew Myers

I think I've solved this.

$temp->set('user_id', $userId);

Did the trick.

Andrew.

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


Returning Model Instance from a different model

2010-08-06 Thread Andrew
Hi,

I have a model called "Setup" and another called "SetupSession" and I
was trying to return a new instance of "Setup" from a method on
SetupSession however I can't seem to get it to work.

My function looks something like this:

// in setup_session.php

function getNextLapSetup($userId, $raceId) {
$count = $this->find('count', array(
'conditions' => array('SetupSession.user_id' =>
$userId, 'SetupSession.race_id' => $raceId)));

if ($count > 0) {
$count = $this->find('first', array(
'conditions' => array('SetupSession.user_id' =>
$userId, 'SetupSession.race_id' => $raceId)));
   // create a new Setup and populate it based on data
retrieved above

  // What needs to go here??

} else {
// return an empty Setup
}
}

In the bit where it says "// What needs to go here??" I've tried a few
things like:

$temp = new Setup();
$temp->data['Setup']['user_id'] = $userId;
// etc
return $temp

But it seems the "data" array (or map, not sure what it's called??) is
undefined.

I also tried the above with $temp->create() after the first line as
well, but am facing the same issue.

Essentially I want to call this function from the controller.  It will
return a new "Setup" model prepopulated with "suggested data", but I
do not require it to be saved to the db until the user reviews it and
re-submits.

I'm primarily a  ColdFusion programmer and new to CakePHP and my PHP
skills are pretty basic so it's entirely possible I'm completely on
the wrong track here.  Is anyone able to advise me what I need to
change to get this working please?

Many thanks,
Andrew.

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

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


Re: Operation syntax

2010-08-06 Thread Weydson Lima
http://www.php.net/manual/en/language.expressions.php

 

If the value of the first subexpression is *TRUE* (non-zero), then the
second subexpression is evaluated, and that is the result of the conditional
expression. Otherwise, the third subexpression is evaluated, and that is the
value.
---
Weydson Lima
weys...@gmail.com


On Thu, Aug 5, 2010 at 12:30 PM, Dave Maharaj  wrote:

>  Can someone explain what the “?” and the ”:” mean?
>
>
>
> return ($this->meta['head_title'] ? $this->meta['page_header'] : NULL);
>
> Does it mean
>
> return $this->meta['head_title'] IF $this->meta['page_header'] IS NULL /
> NOT SET?
>
>
>
> I googled it and looked thru php code but cannot seem to find an
> explanation anywhere.
>
>
>
> Thanks
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others
> with their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.comFor
>  more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
>

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

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


Re: Validation a la "either...or"

2010-08-06 Thread Nabil Alsharif
Look at setting 'required' and 'allowEmpty' in the validation rules...
http://book.cakephp.org/view/127/One-Rule-Per-Field

On Thu, Aug 5, 2010 at 12:19 PM, DerBjörn  wrote:
> Hi,
>
> how do i validate a field in the way of either... or p.e. a field can
> be left blank, BUT IF it has a value i want it to be "numeric". Is
> this possible, is there a workaround or doesn't has it sense at
> all? ;)
>
> Thanks
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+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


Validation a la "either...or"

2010-08-06 Thread DerBjörn
Hi,

how do i validate a field in the way of either... or p.e. a field can
be left blank, BUT IF it has a value i want it to be "numeric". Is
this possible, is there a workaround or doesn't has it sense at
all? ;)

Thanks

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

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


Countries, States and Cities: Which relations i'm dealing with?

2010-08-06 Thread DerBjörn
Hi,

i have three tables: countries, states and cities.

Every country has its capital city, so does every state.
2 relations are very obvious:

state belongsTo country
city belongs to state

Now i have a problem to realize the relations referring to the capital
cities.
In my opinion there are two hasOne relations:

state hasOne city
country hasOne city

Both tables (states and countries) has a column names city_id as
foreign_key, but if i use two hasOnes like

[code]
var $hasOne = array(
'CapitalCity' => array(
'className' => 'City',
'foreignKey' => 'city_id',
'conditions' => '',
'fields' => '',
'order' => ''
)
);
[/code]

i get following error message:
[quote]Warning (512): SQL Error: 1054: Unknown column
'CapitalCity.capitalcity_id' in 'on clause' [CORE/cake/libs/model/
datasources/dbo_source.php, line 681][/quote]

[quote]Query: SELECT COUNT(*) AS `count` FROM `countries` AS `Country`
LEFT JOIN `cities` AS `CapitalCity` ON (`CapitalCity`.`city_id` =
`Country`.`id`) WHERE 1 = 1 [/quote]

Actually it has to be  (`CapitalCity`.`id` = `Country`.`city_id`) to
make sense. What i did wrong?
In a forum i asked i ve been told that to realize the capital city
connections i have to use 2 belongsTo relations, but it doesn't make
any sense to me.

Somebody can enlight me? :)
Thanks!

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

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


Re: Using test cases with model relationships throws error

2010-08-06 Thread generaltao
Hi, thanks for getting back to me.

I definitely have all my models listed in the fixtures collection.
What we just discovered after a lot of testing is that it had to do
with $useTable being set to false. For some reason that just throws
everything out of whack. If anybody gets this in the future, remember
that when using fixtures/designing models that you don't need to put
$useTable=false in, as you're technically using test tables!

Cheers.

On Aug 5, 5:41 pm, jharris  wrote:
> My best guess, without seeing your test case or fixtures, is that you
> need to add the fixture to your $fixtures var in your test case.
>
> i.e.,
>
> class MenuItemTestCase extends CakeTestCase {
>   var $fixtures = array('app.menu_item', 'app.alias');
>
> }
>
> After doing that, they should load into the test DB. Whether or not
> you choose to load them manually or automatically (default) is up to
> you. I'm fairly new to unit testing but it's been my experience so far
> that if a fixture model is related in any way to another model, you'll
> need to include that in your $fixtures var as well. In my case, I have
> to include every model into the $fixtures var.
>
> hth,
> jeremy
>
> On Aug 4, 7:43 am, generaltao  wrote:
>
>
>
> > Hi all,
>
> > Having a strange problem with test cases here. We have two tables in
> > question in this one example -> Alias and MenuItem.
>
> > - Alias belongsTo MenuItem
> > - MenuItem hasMany Alias
>
> > I am running model test cases on Alias itself. Problem is that if I
> > define the "MenuItem hasMany Alias" relationship in the MenuItem
> > itself I get a full-stop error saying
>
> > "Database table aliases for model Alias was not found."
>
> > This is quite obviously bizarre, especially because the prob seems to
> > come from MenuItem model itself. Specific points that are bizarre
> > about this
>
> > 1) For some reason it seems to outright forget to use
> > test_suite_aliases instead of Alias (I have no tables defined for
> > Alias, hence using fixtures!)
>
> > 2) I never say in my fixtures to import the model! I was under the
> > impression you needed to do "var $import" in the fixture to tell it to
> > import model, records, etc. but I'm not doing so in either fixture
> > here. The only thing I have in my fixtures is the standard $name,
> > $records, and $fields.
>
> > Can anyone shed some light on this situation? Why is it "forgetting"
> > to use test_suite_alias if the hasMany is defined in the model? Why is
> > it using model stuff to begin with?
>
> > Cheers!

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


how can i tell cake to delete directories automatically after a specific time

2010-08-06 Thread Tomfox Wiranata
hi,

lets say  a user uploads an image. then i create a temp-folder to save
it temporarily. once the user is finished i delete this temp directory
and copy the image to the actual path.

now lets say, he uploads it, cake puts it to the temp directory and
the user cancels the process by shutting down the browser or just
leaving the website. if that happens, i want to delete the temp-dir.
so is it possible to check if the user left the site or shut down the
browser?

if not, then i'd like to check what temp directories have been created
24hrs ago and still exist, so i can delete them. is that possible?

thank you so far. as usual :)



btw: i love this forum

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

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


Re: How to use home.ctp as a non-static page to include functions?

2010-08-06 Thread Anderson Valongueiro
Great!
Good job!

On 6 ago, 09:15, Chrriss  wrote:
> I used the euromark's solution & it works! Thanks all for your help!
>
> On 6 août, 14:04, Chrriss  wrote:
>
> > I already have the pages_controller.php but when I add 
> > "$this->set("values","This is a test!");", and I dispay in the view, I have
>
> > an error message: undefined variable 'values'...
>
> > On 6 août, 13:07, Anderson Valongueiro
>
> >  wrote:
> > > hi, chrriss,
>
> > > create the controller "pages_controller.php" after to add the display
> > > function("function display"). See below:
>
> > > [pages_controller.php]
>
> > > class PagesController extends AppController {
>
> > >    function display() {
> > >       $this->set("values","This is a test!");
> > >    }
>
> > > }
>
> > > and in the [pages/home.ctp]
>
> > > 
>
> > > On 6 ago, 07:32, Chrriss  wrote:
>
> > > > Hi everyone!
>
> > > > I want to add some functions to my homepage 'home.ctp' but the
> > > > homepage is not considered as dynamic by cakephp as it's located in
> > > > the 'pages' directory. How can I add some functions to my homepage? I
> > > > need to display some informations from the database like the number of
> > > > articles, etc ...
>
> > > > Thanks!

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

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


Re: How to use home.ctp as a non-static page to include functions?

2010-08-06 Thread Anderson Valongueiro
can you show your source? both, the controller and the view.
i already do it, but few times.

try the "euromark" user sugestion too.
i never change my "routes.php" because never need it.


On 6 ago, 09:04, Chrriss  wrote:
> I already have the pages_controller.php but when I add 
> "$this->set("values","This is a test!");", and I dispay in the view, I have
>
> an error message: undefined variable 'values'...
>
> On 6 août, 13:07, Anderson Valongueiro
>
>  wrote:
> > hi, chrriss,
>
> > create the controller "pages_controller.php" after to add the display
> > function("function display"). See below:
>
> > [pages_controller.php]
>
> > class PagesController extends AppController {
>
> >    function display() {
> >       $this->set("values","This is a test!");
> >    }
>
> > }
>
> > and in the [pages/home.ctp]
>
> > 
>
> > On 6 ago, 07:32, Chrriss  wrote:
>
> > > Hi everyone!
>
> > > I want to add some functions to my homepage 'home.ctp' but the
> > > homepage is not considered as dynamic by cakephp as it's located in
> > > the 'pages' directory. How can I add some functions to my homepage? I
> > > need to display some informations from the database like the number of
> > > articles, etc ...
>
> > > Thanks!

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

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


Re: how can I check for a specific value in my session?

2010-08-06 Thread Tomfox Wiranata
i think it worked jeremythank you ;)

On 6 Aug., 13:37, Jeremy Burns | Class Outfit
 wrote:
> You can check if a session element exists by using the check method 
> (http://book.cakephp.org/view/403/check).
>
> So:
>
> if ($this->Session->check('abc.imageuploaded')):
>         do something;
> else:
>         do nothing;
> endif;
>
> Jeremy Burns
> Class Outfit
>
> jeremybu...@classoutfit.comhttp://www.classoutfit.com
>
> On 6 Aug 2010, at 12:33, Tomfox Wiranata wrote:
>
> > hey everyone,
>
> > in my controller I need to make a check if an image was uploaded or
> > not. the way to find this out is to check a specific session variable
> > for its value. lets say the user does upload an image. then I code:
>
> > session.write('abc.imageuploaded', "true);
>
> > in case no image is uploaded I write nothing in this session value.
> > now I tried to make the check like this:
>
> > if ($this->session->read('abc.imageuploaded') == "true"){
>
> > do stuff
>
> > }
>
> > else{
>
> > do other stuff
>
> > }
>
> > unfortunately cake kinda skips my check an executes the if-clause
> > everytime. i also tried
>
> > if (empty($this->session->read('abc.imageuploaded')) but cake doesnt
> > like that at all
>
> > looking forward to your help :)
>
> > thx
>
> > 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


Re: How to use home.ctp as a non-static page to include functions?

2010-08-06 Thread Chrriss
I used the euromark's solution & it works! Thanks all for your help!

On 6 août, 14:04, Chrriss  wrote:
> I already have the pages_controller.php but when I add 
> "$this->set("values","This is a test!");", and I dispay in the view, I have
>
> an error message: undefined variable 'values'...
>
> On 6 août, 13:07, Anderson Valongueiro
>
>  wrote:
> > hi, chrriss,
>
> > create the controller "pages_controller.php" after to add the display
> > function("function display"). See below:
>
> > [pages_controller.php]
>
> > class PagesController extends AppController {
>
> >    function display() {
> >       $this->set("values","This is a test!");
> >    }
>
> > }
>
> > and in the [pages/home.ctp]
>
> > 
>
> > On 6 ago, 07:32, Chrriss  wrote:
>
> > > Hi everyone!
>
> > > I want to add some functions to my homepage 'home.ctp' but the
> > > homepage is not considered as dynamic by cakephp as it's located in
> > > the 'pages' directory. How can I add some functions to my homepage? I
> > > need to display some informations from the database like the number of
> > > articles, etc ...
>
> > > Thanks!

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

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


Re: How to use home.ctp as a non-static page to include functions?

2010-08-06 Thread Chrriss
I already have the pages_controller.php but when I add "$this-
>set("values","This is a test!");", and I dispay in the view, I have
an error message: undefined variable 'values'...

On 6 août, 13:07, Anderson Valongueiro
 wrote:
> hi, chrriss,
>
> create the controller "pages_controller.php" after to add the display
> function("function display"). See below:
>
> [pages_controller.php]
>
> class PagesController extends AppController {
>
>    function display() {
>       $this->set("values","This is a test!");
>    }
>
> }
>
> and in the [pages/home.ctp]
>
> 
>
> On 6 ago, 07:32, Chrriss  wrote:
>
> > Hi everyone!
>
> > I want to add some functions to my homepage 'home.ctp' but the
> > homepage is not considered as dynamic by cakephp as it's located in
> > the 'pages' directory. How can I add some functions to my homepage? I
> > need to display some informations from the database like the number of
> > articles, etc ...
>
> > Thanks!

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

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


Re: How to use home.ctp as a non-static page to include functions?

2010-08-06 Thread euromark
you can just use another controller and action as "home" site

just adjust your routes.php in /config


On 6 Aug., 13:07, Anderson Valongueiro
 wrote:
> hi, chrriss,
>
> create the controller "pages_controller.php" after to add the display
> function("function display"). See below:
>
> [pages_controller.php]
>
> class PagesController extends AppController {
>
>    function display() {
>       $this->set("values","This is a test!");
>    }
>
> }
>
> and in the [pages/home.ctp]
>
> 
>
> On 6 ago, 07:32, Chrriss  wrote:
>
>
>
> > Hi everyone!
>
> > I want to add some functions to my homepage 'home.ctp' but the
> > homepage is not considered as dynamic by cakephp as it's located in
> > the 'pages' directory. How can I add some functions to my homepage? I
> > need to display some informations from the database like the number of
> > articles, etc ...
>
> > Thanks!

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

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


Re: how can I check for a specific value in my session?

2010-08-06 Thread Jeremy Burns | Class Outfit
You can check if a session element exists by using the check method 
(http://book.cakephp.org/view/403/check).

So:

if ($this->Session->check('abc.imageuploaded')):
do something;
else:
do nothing;
endif;

Jeremy Burns
Class Outfit

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

On 6 Aug 2010, at 12:33, Tomfox Wiranata wrote:

> hey everyone,
> 
> in my controller I need to make a check if an image was uploaded or
> not. the way to find this out is to check a specific session variable
> for its value. lets say the user does upload an image. then I code:
> 
> session.write('abc.imageuploaded', "true);
> 
> in case no image is uploaded I write nothing in this session value.
> now I tried to make the check like this:
> 
> if ($this->session->read('abc.imageuploaded') == "true"){
> 
> do stuff
> 
> }
> 
> else{
> 
> do other stuff
> 
> }
> 
> 
> unfortunately cake kinda skips my check an executes the if-clause
> everytime. i also tried
> 
> if (empty($this->session->read('abc.imageuploaded')) but cake doesnt
> like that at all
> 
> looking forward to your help :)
> 
> thx
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en

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

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


how can I check for a specific value in my session?

2010-08-06 Thread Tomfox Wiranata
hey everyone,

in my controller I need to make a check if an image was uploaded or
not. the way to find this out is to check a specific session variable
for its value. lets say the user does upload an image. then I code:

session.write('abc.imageuploaded', "true);

in case no image is uploaded I write nothing in this session value.
now I tried to make the check like this:

if ($this->session->read('abc.imageuploaded') == "true"){

do stuff

}

else{

do other stuff

}


unfortunately cake kinda skips my check an executes the if-clause
everytime. i also tried

if (empty($this->session->read('abc.imageuploaded')) but cake doesnt
like that at all

looking forward to your help :)

thx

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

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


Re: bug with HTML entity encoding of attribute of form elements

2010-08-06 Thread drbuzasi
Of course i mean at my first question: ...different options for title/
selectoptions and for attributes in future versions...


On aug. 6, 13:21, drbuzasi  wrote:
> I think that's not a problem of php escaping. Using double quotes in
> javascript isn't a good idea since the code generated (assuming it
> won't be escaped) would be
> ... onChange="functon("yyy")"...
> which is meanless because of the wrapping double quotes.
>
> IMHO the problem is in form.php and helper.php.
>
> Button problem:
> If 'escape' is set true as option in form.php (CakePHP 1.3.3) line
> 1266 makes title escaped. After then the option remains causing
> attributes getting escaped as well calling _parseAttributes at line
> 1271.
> So title AND attributes will be encoded if 'escape'=>true but none of
> them while set ti false.
>
> Select (and $form->input generally) problem:
> Setting 'escape'=>true HTML encodes only select options because line
> 1426 saves the value for line 1498 but line 1427 unsets this option.
> So when calling _parseAttribute at line 1475 this option is not
> present causing use of default value at line 336 in helper.php.
> Select attributes will be ALWAYS encoded.
>
> Question:
> Should be used different escape options for title/selectoptions in
> future versions of CakePHP? Or the default value in helper.php line
> 336 should be set tu false?
>
> On aug. 6, 06:35, Dan Heberden  wrote:
>
> > Does changing your quote pattern help?
>
> > echo $this->Form->select('field', array( '1' => '' , '2' =>
> > '' ),
> >                                           null, array('onChange' =>
> > 'function(\"yyy\")'));
>
> > \" (because php isn't escaping it) will get sent to the output, which
> > _should_ render
>
> > onclick="function(\"yyy\")" -
>
> > I would do some more tests with sending double quotes vs single quotes
> > for the ent_quote option of the $form helper..
>
> > On Aug 5, 5:27 pm, drbuzasi  wrote:
>
> > > If a button is needed that is labeled as '' and has an
> > > 'onClick' attribute with some javascript containing a text parameter
> > > the code can't be created since when 'escape' is set to false in
> > > options (button default) the script is OK but buttons label will not
> > > be encoded.
> > > Setting 'escape' to true HTML encodes my script, too, which is wrong.
>
> > > echo $this->Form->button('', array('onClick => 'function(\'xxx
> > > \')'));
> > > results
> > > 
>
> > > echo $this->Form->button('', array('onClick' => 'function(\'xxx
> > > \')', 'escape' => true));
> > > results
> > >  > > onClick="function('xxx')">

Re: bug with HTML entity encoding of attribute of form elements

2010-08-06 Thread drbuzasi
I think that's not a problem of php escaping. Using double quotes in
javascript isn't a good idea since the code generated (assuming it
won't be escaped) would be
... onChange="functon("yyy")"...
which is meanless because of the wrapping double quotes.

IMHO the problem is in form.php and helper.php.

Button problem:
If 'escape' is set true as option in form.php (CakePHP 1.3.3) line
1266 makes title escaped. After then the option remains causing
attributes getting escaped as well calling _parseAttributes at line
1271.
So title AND attributes will be encoded if 'escape'=>true but none of
them while set ti false.

Select (and $form->input generally) problem:
Setting 'escape'=>true HTML encodes only select options because line
1426 saves the value for line 1498 but line 1427 unsets this option.
So when calling _parseAttribute at line 1475 this option is not
present causing use of default value at line 336 in helper.php.
Select attributes will be ALWAYS encoded.

Question:
Should be used different escape options for title/selectoptions in
future versions of CakePHP? Or the default value in helper.php line
336 should be set tu false?

On aug. 6, 06:35, Dan Heberden  wrote:
> Does changing your quote pattern help?
>
> echo $this->Form->select('field', array( '1' => '' , '2' =>
> '' ),
>                                           null, array('onChange' =>
> 'function(\"yyy\")'));
>
> \" (because php isn't escaping it) will get sent to the output, which
> _should_ render
>
> onclick="function(\"yyy\")" -
>
> I would do some more tests with sending double quotes vs single quotes
> for the ent_quote option of the $form helper..
>
> On Aug 5, 5:27 pm, drbuzasi  wrote:
>
> > If a button is needed that is labeled as '' and has an
> > 'onClick' attribute with some javascript containing a text parameter
> > the code can't be created since when 'escape' is set to false in
> > options (button default) the script is OK but buttons label will not
> > be encoded.
> > Setting 'escape' to true HTML encodes my script, too, which is wrong.
>
> > echo $this->Form->button('', array('onClick => 'function(\'xxx
> > \')'));
> > results
> > 
>
> > echo $this->Form->button('', array('onClick' => 'function(\'xxx
> > \')', 'escape' => true));
> > results
> >  > onClick="function('xxx')">

Re: How to use home.ctp as a non-static page to include functions?

2010-08-06 Thread Anderson Valongueiro
hi, chrriss,

create the controller "pages_controller.php" after to add the display
function("function display"). See below:


[pages_controller.php]

class PagesController extends AppController {

   function display() {
  $this->set("values","This is a test!");
   }
}


and in the [pages/home.ctp]




On 6 ago, 07:32, Chrriss  wrote:
> Hi everyone!
>
> I want to add some functions to my homepage 'home.ctp' but the
> homepage is not considered as dynamic by cakephp as it's located in
> the 'pages' directory. How can I add some functions to my homepage? I
> need to display some informations from the database like the number of
> articles, etc ...
>
> Thanks!

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

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


How to use home.ctp as a non-static page to include functions?

2010-08-06 Thread Chrriss
Hi everyone!

I want to add some functions to my homepage 'home.ctp' but the
homepage is not considered as dynamic by cakephp as it's located in
the 'pages' directory. How can I add some functions to my homepage? I
need to display some informations from the database like the number of
articles, etc ...

Thanks!

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

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


Re: including php files in my view

2010-08-06 Thread Tomfox Wiranata
thx for the response...i'll give it a ahot :)

On 6 Aug., 02:11, Miles J  wrote:
> You use ajax, the controller and return an HTML response.
>
> http://milesj.me/blog/read/62/Doing-AJAX-Calls-In-CakePHP-Part-1-_-Th...http://milesj.me/blog/read/63/Doing-AJAX-Calls-In-CakePHP-Part-2-_-Th...http://milesj.me/blog/read/64/Doing-AJAX-Calls-In-CakePHP-Part-3-_-Th...
>
> On Aug 5, 8:35 am, Tomfox Wiranata  wrote:
>
> > hi,
>
> > i found this great artice about refreshing 
> > DIVshttp://designgala.com/how-to-refresh-div-using-jquery/
>
> > well that is just fine, but how do i inlcude the file reload.php shown
> > in this line??
>
> > $('#loaddiv').fadeOut('slow').load('reload.php').fadeIn("slow");
>
> > is there a specific directory in cake? since this happens in my view
> > in the  part ???
>
> > can i reuse this line the way it is in cake?
>
> > thank you :)

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