Re: saving HABTM data in a fixture - have to resort to Model::query() to get it done

2012-07-23 Thread Ralf Rottmann
What is in the 'Stuff', 'MoreStuff' and 'StuffToChange' arrays?

On Tuesday, July 24, 2012 2:05:40 AM UTC+2, lsiden wrote:
>
> I created a component test that modifies and saves a model with HABTM 
> associated data.   
>
> Before I upgraded to CakePHP 2.0, I tried to accomplish this with 
> unbindModel() all over my code, but wanted to try something a little 
> cleaner albeit less efficient.  I spent hours reading  
> http://book.cakephp.org/2.0/en/models/saving-your-data.html and wanted to 
> try doing it the "Cake" way: 
>
> $data = array(
>>   'User' => array(
>> 'id' => 99,
>> ...
>>   ),
>>   'Stuff' => array( ... some stuff ...),
>>   'MoreStuff => array( .. more stuff ...),
>>   'StuffToChange' => array( ... this is the stuff I added a record to ...)
>> );
>
>
> When I look at the query log, Cake generated queries to delete Stuff, 
> MoreStuff, and ReallyImportantStuff, but only does inserts into 
> StuffToChange.
>
> I'm wondering if this is somehow related to the fact that I'm using 
> fixtures in my test.  I suppose I could clone the real database and try it 
> on that to see if its a fixture problem.  (I'm too exhausted now to try 
> anything.  I need a break!)  
>
> So in order to make progress I had to give up for now and do it the "brute 
> force" (but much more effiicient way):
>
> $model->query("insert into stuff_to_change where user_id=99 and 
>> something_id=xxx")
>
>
> I suppose Cake purists will tell me that this is wrong and could create 
> problems in the future if I were to migrate the data to a different 
> database platform, for example, but I wasted half a day trying to get this 
> to work and I can't afford to spend much more time when I have a 
> functioning workaround.  Even if it turns out to be an issue that will only 
> happen when I use my fixtures, I want it to work the same way in a unit 
> test as it works in the field.
>
> Anyone else having this problem in Cake 2.x?  (I'm actually in the master 
> branch from the Git repo - yeah, I'm bleeding edge now).
>

-- 
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: How to connect to Microsoft Access in cakephp 1.3 ?

2012-07-23 Thread Dr. Tarique Sani
You will need to use the ODBC datasource - I don't know if this works
with 1.3 
https://github.com/cakephp/datasources/blob/master/models/datasources/dbo/dbo_odbc.php

HTH

Tarique

On Tue, Jul 24, 2012 at 11:46 AM, Cruisine  wrote:
> hi guys,
>
> do you happen to know how to connect to M.Access database in cakephp ?
> i've been trying to search thread which related to this case but there's no
> satisfied answer for this case.
>
> i need to know the answer very soon. many 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



-- 
=
PHP for E-Biz: http://sanisoft.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


How to connect to Microsoft Access in cakephp 1.3 ?

2012-07-23 Thread Cruisine
hi guys,

do you happen to know how to connect to M.Access database in cakephp ?
i've been trying to search thread which related to this case but there's no 
satisfied answer for this case.

i need to know the answer very soon. many 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: Cake PHP User Management Plugin Eagle

2012-07-23 Thread gavrielh
The site links do not work - can't login as "admin" to test the site... 
 Looks cool, but little time to test without working.

On Monday, July 23, 2012 3:30:04 AM UTC-7, Albert 'Tigr' wrote:
>
>
>
> On Sunday, 22 July 2012 13:17:43 UTC+2, Steve wrote:
>>
>>
>> This Eagle Plugin was made for a user who is facing problem with 
>> Login/Registration and other issues. It has 56 features. Please don't 
>> concentrate on design, everything is code. 
>>
>
>
>
> Ok, where is the code then?
>
> Albert
>  
>

-- 
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: Problem with multiple testAction calls with mocked Auth component - 2.2.1

2012-07-23 Thread Dr. Tarique Sani
Thumbrule - one testAction per test

HTH
Tarique


On Tue, Jul 24, 2012 at 6:14 AM, Dave M.  wrote:
> I've discovered this doesn't happen when i am logged in to the app itself.
> I am quite confused.
>
>
> On Monday, July 23, 2012 10:58:34 AM UTC-4, Dave M. wrote:
>>
>> After upgrading to 2.2.1 from 2.0.x some of my controller tests are
>> failing.
>> It seems as if a mocked Auth component does not survive multiple
>> testAction calls. Am I doing something wrong here or is this expected?
>>
>> CandidatesControllerTest.php
>> public function testExportAdmin() {
>> $Candidates = $this->generate('Candidates', array(
>> 'components' => array('Auth' => array('user'))
>> ));
>>
>> $Candidates->Auth
>> ->staticExpects($this->any())
>> ->method('user')
>> ->with($this->equalTo('type'))
>> ->will($this->returnValue('admin'));
>>
>> $this->testAction('/candidates/export/active.csv');
>> $this->assertEquals(2, count($this->vars['data']));
>>
>> $this->testAction('/candidates/export/historical.csv');
>> $this->assertEquals(3, count($this->vars['data']));
>> }
>>
>> Throwing a debug call in my CandidatesController.php for
>> $this->Auth->user('type') returns 'admin' on the first testAction, but null
>> on the second.
>>
>> Any ideas?
>
> --
> 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



-- 
=
PHP for E-Biz: http://sanisoft.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


Re: Test Case and login

2012-07-23 Thread Dr. Tarique Sani
use something like $this-Controllername->Session->write() and write
whatever your login is writing to session. Remember you are Unit
testing your controller not your login :-)

HTH
Tarique


On Mon, Jul 23, 2012 at 9:39 PM, Juan Ezquerro LLanes  wrote:
> Hi,
>
> I write a test case for a controller but i need a user logged to do the
> test, i try something like:
>
>  public function testIndex()
> {
> // TEST USER NORMAL 
> $this->Auth->login(
> array(
>  'user' => 'aa',
>  'client_id' => 12345678,
>  '_row_key' =>
> serialize(UUID::import('0fbr75bgrjv7buyygu78h6gugbu35gbu9'))
> )
> );
> $this->_testAction(
> '/SermepaConfig/index',
> array('return' => 'vars')
> );
> debug($this->vars);
>
> $this->Auth->logout();
> }
>
> But $this->vars is empty:
>
> ## DEBUG ##
> array(
> 'clients_list' => array(
> (int) 0 => false
> )
> )
>
> How can i test actions with several levels of access by user?
>
> I  can do something like assertEqual calling $this->MyController->function()
> but not run if the call to the action must be a post ajax data, like:
>
>
>  $_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest';
>
> $this->_testAction(
> '/SermepaConfig/get_filtered_list',
> array(
>  'data' => array(
>  'SermepaConfig' => array(
>  'client_id' => 123456
>  )
>  ),
>  'method' => 'post',
>  'return' => 'result'
> )
> );
>
> --
> 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



-- 
=
PHP for E-Biz: http://sanisoft.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


Re: Problem with multiple testAction calls with mocked Auth component - 2.2.1

2012-07-23 Thread Dave M.
I've discovered this doesn't happen when i am logged in to the app itself.
I am quite confused.

On Monday, July 23, 2012 10:58:34 AM UTC-4, Dave M. wrote:
>
> After upgrading to 2.2.1 from 2.0.x some of my controller tests are 
> failing. 
> It seems as if a mocked Auth component does not survive multiple 
> testAction calls. Am I doing something wrong here or is this expected?
>
> CandidatesControllerTest.php
> public function testExportAdmin() {
>  $Candidates = $this->generate('Candidates', array(
> 'components' => array('Auth' => array('user'))
> ));
>
> $Candidates->Auth
> ->staticExpects($this->any())
> ->method('user')
> ->with($this->equalTo('type'))
> ->will($this->returnValue('admin')); 
>
> $this->testAction('/candidates/export/active.csv');
> $this->assertEquals(2, count($this->vars['data']));
>
> $this->testAction('/candidates/export/historical.csv');
> $this->assertEquals(3, count($this->vars['data']));
> }
>
> Throwing a debug call in my CandidatesController.php 
> for $this->Auth->user('type') returns 'admin' on the first testAction, but 
> null on the second.
>
> Any ideas?
>

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


saving HABTM data in a fixture - have to resort to Model::query() to get it done

2012-07-23 Thread lsiden
I created a component test that modifies and saves a model with HABTM 
associated data.   

Before I upgraded to CakePHP 2.0, I tried to accomplish this with 
unbindModel() all over my code, but wanted to try something a little 
cleaner albeit less efficient.  I spent hours reading  
http://book.cakephp.org/2.0/en/models/saving-your-data.html and wanted to 
try doing it the "Cake" way: 

$data = array(
>   'User' => array(
> 'id' => 99,
> ...
>   ),
>   'Stuff' => array( ... some stuff ...),
>   'MoreStuff => array( .. more stuff ...),
>   'StuffToChange' => array( ... this is the stuff I added a record to ...)
> );


When I look at the query log, Cake generated queries to delete Stuff, 
MoreStuff, and ReallyImportantStuff, but only does inserts into 
StuffToChange.

I'm wondering if this is somehow related to the fact that I'm using 
fixtures in my test.  I suppose I could clone the real database and try it 
on that to see if its a fixture problem.  (I'm too exhausted now to try 
anything.  I need a break!)  

So in order to make progress I had to give up for now and do it the "brute 
force" (but much more effiicient way):

$model->query("insert into stuff_to_change where user_id=99 and 
> something_id=xxx")


I suppose Cake purists will tell me that this is wrong and could create 
problems in the future if I were to migrate the data to a different 
database platform, for example, but I wasted half a day trying to get this 
to work and I can't afford to spend much more time when I have a 
functioning workaround.  Even if it turns out to be an issue that will only 
happen when I use my fixtures, I want it to work the same way in a unit 
test as it works in the field.

Anyone else having this problem in Cake 2.x?  (I'm actually in the master 
branch from the Git repo - yeah, I'm bleeding edge now).

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


Get Data about Current Page

2012-07-23 Thread Andrew Johnston
How would I get data for a current view? For example, if I had the page:
http://example.com/view/2

and I wanted to link to:

http://example.com/view/3

How would I do that? I don't use Paginator. 

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


Using test database

2012-07-23 Thread Juan Ezquerro LLanes
If i write a test case i want use the test database config without 
fixtures, i insert the data manually, i just want to say to my test case 
'just use that db with the data and tables already contains'. how can i do 
that? fixtures do not work with my datasource, i'm using cassandra.

-- 
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: What security issues do I have to worry about when it comes to CakePHP?

2012-07-23 Thread euromark
using the security component is an absolute requirement for beginners. 
especially due to missing whitelisting in default templates.
besides that you pretty much only need to make sure you don't output 
unescaped output - using h($var)
that should take care of most of the basic problems



Am Montag, 23. Juli 2012 20:04:22 UTC+2 schrieb Shahruk Khan:
>
> I know CakePHP does a lot of stuff for you, but if I setup a CakePHP 
> installation and create a CRUD app, is that it, or do I have to do anything 
> else to make sure the platform is secure?

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


Conceptual questions regarding HABTM relationships!

2012-07-23 Thread Ralf Rottmann
I've been working with CakePHP (2.x) for quite a while and I'm loving it. 
However, I found some very important aspects covered too briefly in the 
documentation. When googling around and asking in other forums, I got mixed 
responses, increasing my feeling of uncertainty even more.

I'd like to ask this group to help me (and possibly others) clarifying a 
few questions. I've used Pastie for code as I frequently find long code 
snippets in group posts hurting readability.

Here we go:

Assume I've got two models, User and Group related to each others in a 
HABTM relationship. Each user can have multiple groups and groups belong to 
multiple users. My simple model definition  is 
here: http://pastie.org/4307801. Also, the join table *groups_users* exists 
with the appropriate columns following CakePHP's conventions.

1. Question:
a) Assuming that all tables are empty, can I add a *new user* along with *a 
single new group* and the corresponding entries in the join table in one 
*single 
command*? I tried this http://pastie.org/4307843. The user gets created, 
but no group nor does anything get inserted into the join table.

b) In case I did anything wrong in a) and it is in fact possible to create 
a User and Groups on the fly in one single command, is it also possible to 
create *multiple* groups? If so, would this http://pastie.org/4307863 be 
the correct way of doing it?

c) Is this what *saveAll()* and *saveAssociated()* where meant for?

2. Question:
What exactly is the difference between *save()*, *saveAll()* and *
saveAssociated()*?

3. Question:
In past versions of CakePHP it was difficult to have CakePHP add *additional
* related items (= records to the join table) as CakePHP annoyingly deleted 
any existing records in the join table before adding new ones for an 
existing relationship. If, e.g. the user would join additional groups, 
there was no easy way doing it in CakePHP besides taking care for inserting 
the correct records in the join table yourself. As far as I remember 
somebody wrote a behavior to circumvent this but it didn't get updated and 
no longer works.

What is the best way in CakePHP to add additional related objects (not new 
relationships!) when some already exist? Am I supposed to just manually *
save()* records to the join table using the implicit join table model?

4. Question:
Last but not least: Give the above and the use case, how would a 
professional, experience CakePHP developer handle the following use cases 
(code welcomed!):

a) Adding the first group to an existing user.
b) Later, adding additional groups to that user.
c) Later, removing some of the groups.

I hope to hear back from the community. You can also find me on Twitter 
@ralf .



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


Saving more than one related object in a HABTM scenario

2012-07-23 Thread Ralf Rottmann
Code also available here: http://pastie.org/4308149

My models User and Group share a hasAndBelongsToMany relationship. The 
following code create the new user, creates the new group and inserts the 
correct entry into the groups_users join table. This tells me, the 
relationship is configured correctly and working.

Question: If I want to save more than a single group, e.g. the user is in 
three groups, how would I have to modify my code?

public function tryHabtm() {
$this->deleteRecords(); 
$this->User->set(
array(
'id' => null,
'name'=>'Foo Bar',
'email'=>'foo@example.com',
'password'=>'secure',
'password_confirmation'=>'secure',
'role'=>'admin',
'company'=>'CakePHP Inc',
'dealer_number'=>'1',
'phone'=>'+49 111 222 333',
'status'=>'true',
* 'Group'=>$this->Group->save(array('id'=>null, 'name'=>'Debugger')) // ** 
WHAT DO I HAVE TO DO HERE TO ADD MULTIPLE RELATED GROUPS FOR THIS USER???*
)
);
 $this->User->save();
}

-- 
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: Connecting to a ReSTful API (Google apps) instead of a database.

2012-07-23 Thread Andrew Lechowicz
Also, I found this on 
StackOverflow.
 
But I'm not sure how I would use 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


What security issues do I have to worry about when it comes to CakePHP?

2012-07-23 Thread Shahruk Khan
I know CakePHP does a lot of stuff for you, but if I setup a CakePHP 
installation and create a CRUD app, is that it, or do I have to do anything 
else to make sure the platform is secure?

-- 
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: Connecting to a ReSTful API (Google apps) instead of a database.

2012-07-23 Thread Andrew Lechowicz
Not that it matters but the path where I put the google library actually 
reads "app/Vendor/GoogleAPI/"

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


Connecting to a ReSTful API (Google apps) instead of a database.

2012-07-23 Thread Andrew Lechowicz
Hello all and thanks for reading my topic.

First let me say that I've very new to CakePHP and MVC in general so please 
bare with me.  I have actually read The Book and found it to be a great 
starting point, and the main reason I chose Cake over other PHP MVC 
frameworks.

I'm working on a webservice that integrates with Google's Apps 
API. 
I would like Cake to essentially use google as the database for many of my 
functions such as Authenticating a user, and CRUD with their calendar 
events, contacts etc.

I know I'll be needing to use OAuth 2.0 however, Google has a 
library that 
I would like to integrate with Cake that would take care of this, and I 
believe that is my first step. I have gone as far as adding it to my 
to app/vendors in a /GoogleAPI folder. I have also tested the API as a 
stand alone site on my local network and I am able to get a response from 
Google with the correct calendar information from a google account. I used 
Google's 
PHP calendar API 
Sample
 to accomplish this.

Has anyone done anything like this before or can one point me in the right 
direction? What are my next steps?

I'm using CakePHP 2.2.1

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


Test Case and login

2012-07-23 Thread Juan Ezquerro LLanes
Hi,

I write a test case for a controller but i need a user logged to do the 
test, i try something like:

 public function testIndex()
{
// TEST USER NORMAL 
$this->Auth->login(
array(
 'user' => 'aa',
 'client_id' => 12345678,
 '_row_key' => 
serialize(UUID::import('0fbr75bgrjv7buyygu78h6gugbu35gbu9'))
)
);
$this->_testAction(
'/SermepaConfig/index',
array('return' => 'vars')
);
debug($this->vars);

$this->Auth->logout();
}

But $this->vars is empty:

## DEBUG ##
array(
'clients_list' => array(
(int) 0 => false
)
)

How can i test actions with several levels of access by user?

I  can do something like assertEqual calling 
$this->MyController->function() but not run if the call to the action must 
be a post ajax data, like:


 $_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest';

$this->_testAction(
'/SermepaConfig/get_filtered_list',
array(
 'data' => array(
 'SermepaConfig' => array(
 'client_id' => 123456
 )
 ),
 'method' => 'post',
 'return' => 'result'
)
);

-- 
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: Ingherited models that filter active users/records?

2012-07-23 Thread geste
Thanks to you and Mike and Jeremy for responses.  Not only do I have 
confirmation that I was headed in the right direction, model-wise, with 
some examples, but you have prodded me to expand my use of MySQL 
constructs.  To date I haven't used a VIEW, but it would seem that one big 
advantage could be taking the filter logic out of Cake (no always the 
fastest!) and shifting it to the DB back end. Not quite a stored procedure 
but maybe same effect.

Thanks again!

Jim


On Saturday, July 21, 2012 7:03:04 AM UTC-7, Ratty wrote:
>
>  On 20/07/12 17:44, geste wrote:
>  
> I have a business system with a table called "People" and where we retain 
> records of a Person even when they leave our organization.  Each record has 
> an "active" attribute that indicated if somebody is active (Duh!).
>  
>  However, I find myself writing a lot of snippets in controllers that 
> essentially go "WHERE active = '1'" and that seems like it could be a pain 
> and error-prone over time.
>
>  What I'd like to do is leave "People" alone but create a new model or 
> model called "Users" that simply flters People for active=1.  And maybe a 
> corresponding model that is OldUsers and feteches active=0.
>
>  I started to implement something like this at the controller level but 
> then asked myself why not implement at Model level.  Does this seems liek a 
> rational approach.  Can anyone point to some good examples outside of basic 
> API docs?
>
>  Thanks,
>
>  Jim
>
>  -- 
> 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
>
> You *could* implement this as 2 database views as opposed to tables. So 
> 'Users' and 'OldUsers' would simply be 2 views on the 'People' table.
>
> In MySQL this becomes...  CREATE VIEW OldUsers AS SELECT * FROM People 
> WHERE active='0';
>
> OldUsers is then effectively a read-only table and CakePHP is quite happy 
> to generate a model for 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


Problem with multiple testAction calls with mocked Auth component - 2.2.1

2012-07-23 Thread Dave M.
After upgrading to 2.2.1 from 2.0.x some of my controller tests are 
failing. 
It seems as if a mocked Auth component does not survive multiple testAction 
calls. Am I doing something wrong here or is this expected?

CandidatesControllerTest.php
public function testExportAdmin() {
 $Candidates = $this->generate('Candidates', array(
'components' => array('Auth' => array('user'))
));

$Candidates->Auth
->staticExpects($this->any())
->method('user')
->with($this->equalTo('type'))
->will($this->returnValue('admin')); 

$this->testAction('/candidates/export/active.csv');
$this->assertEquals(2, count($this->vars['data']));

$this->testAction('/candidates/export/historical.csv');
$this->assertEquals(3, count($this->vars['data']));
}

Throwing a debug call in my CandidatesController.php 
for $this->Auth->user('type') returns 'admin' on the first testAction, but 
null on the second.

Any ideas?

-- 
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: How to pass id through a form to another controller and view form

2012-07-23 Thread Guti Grewal
Hi, 
Thanks this works almost perfectly apart from it is not echoing out the 
value in the hidden field :S it just leaves it blank, any idea why?

On Sunday, 22 July 2012 19:20:30 UTC+1, cricket wrote:
>
> On Sun, Jul 22, 2012 at 8:19 AM, Guti Grewal  
> wrote: 
> > 
> > What I want to do is get the galleryid to be inserted into the images 
> table, 
> > through a form, which you can see above once a gallery is added it 
> redirects 
> > to images/add, I want to get the last inserted id into the form in the 
> > images/add form so that I am able to call on the related ones 
>
> $this->redirect( 
> array( 
> 'controller' => 'images', 
> 'action' => 'add', 
> 'gallery_id' => $this->Gallery->getInsertID() 
> ) 
> ); 
>
>
> Route::connect( 
> '/images/add/:gallery_id', 
> array( 
> 'controller' => 'images', 
> 'action' => 'add' 
> ), 
> array( 
> 'gallery_id' => '[0-9]+' 
> 'pass' => 'gallery_id' 
> ) 
> ); 
>
> public function add($gallery_id = null) 
> { 
> $this->set(compact('gallery_id')); 
> ... 
> } 
>
> $this->Form->hidden('Image.gallery_id', array('value' => $gallery_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


Re: User management and authentication plugin for CakePHP 2

2012-07-23 Thread Albert 'Tigr'
Yes, that is precisely what I already do. The question is whether the 
automagic selection of the language-specific views is available and the 
answer, as far as I can see, is "no".

On Sunday, 22 July 2012 11:08:29 UTC+2, Piotr Beschel wrote:
>
> So try to check prefered language for user 
> $_SERVER['HTTP_ACCEPT_LANGUAGE'];
>
> W dniu niedziela, 22 lipca 2012 07:33:49 UTC+2 użytkownik Albert 'Tigr' 
> napisał:
>>
>> Hi!
>>
>> On Saturday, July 21, 2012 11:23:52 AM UTC+2, Piotr Beschel wrote:
>>>
>>> *If i'm right u can use echo __('some text') in your email views.*
>>>
>>>
>> Yes, but that is inefficient. You'd have to split the text in small 
>> chunks (length limits!) and translate them through the .po files. I'd 
>> rather have texts in different languages and have the system pick up one. 
>> There is only a couple of variables and the rest is, well, just text in a 
>> particular language.
>>
>>  
>>
>>> My tip for you: Do not repeat yourself! Write a private function 
>>> __blockRobots(){
>>> end call it when you need it in other actions like:
>>>
>>>
>> A long overdue action and not only there. I will. Thanks a lot!
>>
>> Albert
>>  
>>
>

-- 
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: Cake PHP User Management Plugin Eagle

2012-07-23 Thread Albert 'Tigr'


On Sunday, 22 July 2012 13:17:43 UTC+2, Steve wrote:
>
>
> This Eagle Plugin was made for a user who is facing problem with 
> Login/Registration and other issues. It has 56 features. Please don't 
> concentrate on design, everything is code. 
>



Ok, where is the code then?

Albert
 

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


I am not getting the paypal_ipn plugin implementation going on. The initial setup for each and every detail is required can anyone guide or redirect to link.

2012-07-23 Thread Roshan

The initial setup for each and every detail is required such as putting the 
plugin folder to setting the particular parameters in different files. Can 
anyone guide or redirect to link.
I have tried http://www.micahcarrick.com/paypal-ipn-with-php.html link also 
but it does not tell all the details.

-- 
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 with barcode

2012-07-23 Thread Борислав Събев
This is right. Nowadays almost all (except special-purpose ones) emulate a 
gerenic keyboard device. 
I have personally coded a barcode generation application in CakePHP, but 
the reader part was handled by some Air applications.
Nevertheless barcode readers do "just throw the string that they've read to 
the standard input (stdin)". This does mean that 
you can have a web frontend with some inputs that gets this string and does 
whatever with it. However there are some things to
consider:

1. Most barcode readers that work like this will throw in a carriage return 
as the last symbol which my result in form submission, if not handled 
properly. (This as may other features is configurable in the scanner 
itself.)
2. You should use an autofocus on the field that the reader will populate 
because otherwise the browser may think that this is an URL to follow and 
it will do so, because of the carriage return at the end.
3. You should see to that the interface design of the application copes 
with the restrictions imposed by the usage of this unusual human interface 
- a barcode scanner.

All Barcode scanners have a ROM with some configuration options in it and 
if you need anything special you should check the documentation for the 
scanners you're going to use.

Regards, 
   Mr. Software Engineer - Barcode Specialist :D

On Saturday, 21 July 2012 16:51:59 UTC+3, Ratty wrote:
>
>  On 05/07/12 17:13, Mr. Manager wrote:
>  
> Dear All,
>
> If everyone know the solution to deal with my issue is that I would like 
> to build an application that manage product with cakephp and also use with 
> barcode, the requirement is that I want to generate barcode for products 
> with respect to their id and also read barcode from barcode scanner and 
> process in the application to show data of the product and calculate the 
> price for invoicing.
>
> I am looking forward to hearing good news from all of you as soon as 
> possible.
>
> Best Regard,
> Mr. Manager,
> -- 
> 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
>
>
> Do you mean a hand scanner as in a scanner that plugs into a USB ?
>
> If that is the case, they usually emulate a USB keyboard, so all you need 
> is an input field. I have used this in a book application in which the ISBN 
> or EAN barcode on the back of the book is scanned. The barcode reader 
> decodes the barcode for you as long it is a supported format and sends you 
> the characters it finds. This gives you the flexibility of either entering 
> the barcode characters by hand or scanning them which can be useful if your 
> scanner breaks !
>
> For Generation there is a helper published at the bakery that looks pretty 
> comprehensive and it just requires the GD php extension.
>
> http://bakery.cakephp.org/articles/ixu38/2010/04/30/barcode-helper
>  

-- 
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: $title_for_layout and what changes I need to do

2012-07-23 Thread Sam Sherlock
You using 2.x right?
Don't worry about the yet as its 3.0 specific.

- S
On 15 Jul 2012 11:23, "Nvp"  wrote:

> Hi!
> It's my first Cake project I have about 5-6 static pages they are served
> by the default PagesController.
>
> I havein my layout file
> and set('title_for_layout', 'Page Title'); ?> in my views
> files.
> So as I read on API page $title_for_layout is deprecated and will be
> removed in CakePHP 3.0, and I should use title_for_layout instead.
>
> But I don't understand how and what changes I should do in my layout/view
> files.
> Can anyone provide me an example please?
>
>
> 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