Re: Why CakePHP ?

2014-09-03 Thread David Suna
If all you need is a CMS I would suggest using an existing CMS rather than 
trying to build one yourself in any language. There are many good CMS 
packages available and some of them are based on CakePHP. CakePHP, or 
another framework regardless of the language it is based on, is appropriate 
for developing custom web applications that cannot be addressed by existing 
software packages.


-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Does CakePHP 2.5 support the HSTORE and ARRAY data types from PostgreSQL?

2014-07-22 Thread David Suna
We are looking into what framework to use for a new project. One of the 
requirements of the project is to use PostgreSQL and take advantage of the 
Postgres specific data types like HSTORE. Is that something that CakePHP 
supports?

Thanks.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: Form field which is displayed only

2014-06-12 Thread David Suna
Why are you using a form field at all? If you just want to display the data 
then just output the data as text.

On Tuesday, June 3, 2014 2:13:58 PM UTC+3, th...@gmx.at wrote:
>
> I'm using CakePHP 2.4.9
> In my application I want to have a readonly field where I display data 
> which cannot be changed. E.g., a persons country: there is a hidden field 
> with the country ID and a readonly text field with the countries name. The 
> user can see the persons country but is not able to change it. So I do in 
> the edit.ctp
>
>
> $this->Form->input('Person.country_id', array('type' => 'hidden', ...));
>
> $this->Form->input(null, array('type' => text, 'value' => 'Country', 
> 'readonly' => 'readonly', ...)
>
> The expected outcome is that only the data of the hidden field are posted 
> on submit but not the data of the readonly field.
> But what I have is that both fields have the name '[Person][country_id]' 
> and both fields are part of the submit data.
>
> Is there a way to format such informative readonly fields like any other 
> form data, but not include them in the form data on submit?
>
> In the FormHelper I see that the setEntity does not change _entityPath if 
> the $fieldName parameter is null, it just remains what it was before. Is 
> that intended?
>
> I can, of course, use an invalid model. e.g. 
>
> $this->Form->input('Invalid.country', ...)
> But that looks like an ugly hack to me.
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Using PHPUnit for code that requires basic authentication

2013-09-30 Thread David Suna
How do I write test cases in PHPUnit for code that is using the Auth module 
with basic authentication? I have found bits and pieces of information 
about it but does anyone know of a step by step howto or detailed 
documentation?

My code limits certain actions to certain user types so it calls the 
Auth->login method and then gets the user object from Auth ($User = 
$this->Auth->user()) and then checks the group_id ($User['group_id']).

There seem to be two approaches to this:
1. Mock the User object and the Auth component
2. Read the User information from the database and call Auth->login 
explicitly in the test setup

Which approach is "best practice"? Are there some cases where it is better 
to use one over the other?

Unfortunately, I have no real experience using PHPUnit or other unit 
testing frameworks.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Putting custom code in a separate repository

2013-09-09 Thread David Suna

On Monday, September 9, 2013 5:05:04 PM UTC+3, Jeremy Burns : 
class...@classoutfit.com wrote:
>
> You add submodules in a path relative to the root of the git repository. I 
> am a Git command line coward so use SourceTree (http://sourcetreeapp.com) 
> which does it all for me. I have all (most) of my plugins as submodules.
>
> Yes - this approach would work well for plugins as they have their own 
directory structure and everything for a plugin is contained below one 
parent directory. However, for general Cake code (i.e. models, views and 
controllers) there is no isolated directory point under which all of these 
would be done.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Putting custom code in a separate repository

2013-09-09 Thread David Suna

On Monday, September 9, 2013 4:58:06 PM UTC+3, Simon Males wrote:
>
> Some people have made lib/Cake a submodule
>
> https://github.com/nodesagency/cakephp-lib
>

This sounds like it would work although it is somewhat of a shame to leave 
out all the code under app. My question would be how to get started.  If I 
just clone the cakephp-lib where do I get the code under app from? Take it 
from a zip file?

Another suggestion is too have cakephp/cakephp as an remote named 
> 'upstream'. Then you could suck in changes via `git fetch upstream`, but it 
> could get messy in the app directory.
>
 
As the app directory is what I am most interested in I don't think I want 
to go for messy. 

-- 
> Simon Males 
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Putting custom code in a separate repository

2013-09-09 Thread David Suna
Thanks for the suggestion.

>From a quick look at git submodules it seems that they are geared to using 
them in a single directory.  The changes to a clean CakePHP installation 
end up being across multiple directories as well as include changes to some 
of the files in the original CakePHP repository.  I didn't see how 
submodules would handle that situation.  Do you have a reference that would 
explain this more?

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.


Putting custom code in a separate repository

2013-09-09 Thread David Suna
I started a project locally by cloning the git repository for CakePHP 
(branch 2.4). I would like to maintain the ability to do a pull on the git 
repository to get any updates as new releases are put out.  I assume I 
should be on branch 2.4 rather than on master.

I would also like to have my code in a separate repository.  That includes 
any changes I made to files that come as part of the CakePHP repository (so 
far this includes app/Config/bootstrap.php, app/Config/core.php, 
app/Config/routes.php and app/Controller/AppController.php) as well as 
files that I have added (i.e. everything under Config, Controller, Model, 
Test, View and webroot).

There are also Plugins that have been retrieved from other repositories but 
since those are contained under a single directory that isn't a problem to 
maintain.

Does anyone have a recommendation as to how to go about doing this?

Thanks.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.


Re: User Defined Dashboard?

2013-09-02 Thread David Suna
If I understand the problem correctly I would restate it as:
There are dashboard items (DashboardItem) that can be displayed on a 
dashboard.  There is a relationship between user groups (Group) and a 
subset of dashboard items defining which dashboard items can be displayed 
for that group.  You want to add a relationship between the user (User) and 
the subset of dashboard items that are available to the group and allow 
them to choose which of those items will be displayed on their personal 
dashboard.

If that problem statement is correct then you would want to do something 
with a HABTM relationship between DashboardItem and Group as well as a 
HABTM relationship between DashboardItem and User with the limitation that 
only items that satisfy the constraint of being in the list of 
DashboardItems associated with a particular group are available to be 
included in the DashboardItems that can be associated with a User.

You will probably need custom code in the afterDelete and afterSave 
callbacks of the group_dashboard_items model that will update the 
user_dashboard_items model to remove or insert additional relationships.

This does not address the actual content of your DashboardItems which would 
presumably be generated on the fly from other models (as others have 
already pointed out in their responses).

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.


parseExtensions and ssl

2013-09-02 Thread David Suna
I am developing a REST API. I have it working using paresExtensions and 
mapResources.  However, if I try to access the API using ssl (https instead 
of http) the routing does not seem to work and I get an error 

Missing Method in TenantsController 
>
> *Error: * The action *30.json* is not defined in controller *
> TenantsController*
>
What do I have to do to get this to work together with SSL?

I want to enable the Security component and requireSecure for the entire 
API as well.  That seems to work but also has the same problem of the 
broken routing.

Thanks.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Throwing error should output JSON

2013-08-28 Thread David Suna
Replying to myself - this is what I found.

The presentation that I saw that said that putting error400.ctp in a json 
folder under /app/View/Errors would work automatically seems to be 
incorrect.

The solution I came up with included the following steps:
1. Set a flag in app/Controller/AppController indicating that this is a 
REST call. As there does not seem to be an is("rest") or isRest call I did 
this based on the extension.
In AppController.php within the AppController class add:
  public $REST = FALSE;

  function beforeFilter()
  {
// Add additional checks here to support other formats
if (isset($this->request->params['ext']) && 
($this->request->params['ext'] == 'json'))
{
  $this->REST = 'json';
}
$this->set('REST', $this->REST);
  }

2. Using the comments from COTP that I found 
hereI
 copied CakeErrorController.php into my app/Controller folder and added a 
beforeRender method:
  public function beforeRender()
  {
parent::beforeRender();
// If this is a REST call then use the views for that format type
if ($this->REST)
{
  $this->viewPath = "Errors/" . $this->REST;
  // The documentation 
says
 
to set the layout in the view files but it seems
  // more efficient to put it here once then in all of the view files
  // Use a different layout if you want something special. ajax layout 
just
  // outputs the view content with nothing else
  $this->layout = 'ajax';
}
  }
 
3. Now I can create View/Errors/json/error400.ctp:
{"Error": 
  {
"code": getCode(); echo $Code; ?>,
"description": "response->httpCodes($Code); echo 
$Status[$Code] . ": " . $error->getMessage(); ?>"
  }
}

Hope this helps someone

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.


Throwing error should output JSON

2013-08-28 Thread David Suna
I am developing a REST API using the latest CakePHP.  I was under the 
impression (from a presentation I watched on YouTube from CakeFest 2010) 
that I could throw an error and have it return the error as JSON to the 
client by adding a json direction below /app/View/Errors and adding the 
appropriate error file (i.e. error400.ctp) in that directory.  The API 
itself is working (i.e. if I call /tenants/30.json it returns the tenant 
with id 30 as json).  However, when I throw a NotFoundException it is 
outputting the HTML template under /app/View/Errors/error400.ctp instead of 
the json template under /app/View/Errors/json/error400.ctp.

What do I have to do to get it to output the json template?


-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.


Best practice for Helpers

2013-07-16 Thread David Suna
As a best practice, should a helper output content or return the content to 
the View?

In other words, should the call to the helper be:
$this->MyHelper->someMethod($DataForHelper);

or

echo $this->MyHelper->someMethod($DataForHelper);

Most of the built in helpers seem to prefer the latter form.  Is this just 
a style issue or is there a preferred way?

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Generating multiple 'requests' based on form selections

2013-06-30 Thread David Suna
I think your use of the term "request" is confusing. Do you need the client 
to issue six requests to the server with the various combinations? Or can 
the client issue a single request with all of the information and have the 
server process that as a request for six new records to be created?

If you need to actually issue six separate requests then the way I could 
think of doing it would be using JavaScript. Capture the submit button 
event and then use AJAX calls to issue the separate requests. This is a 
very messy way to do it as you would need to build into the client error 
handling and roll back for partially executed requests.

If you can have the single request then basically all of the work happens 
on the server.  I haven't used CakePHP 1.1 but in 1.3 you could generate an 
array of the model you want to save and call saveAll.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Saving session data from a view

2013-06-16 Thread David Suna
Thanks for your response.

As I had no choice that is what I ended up doing.  However, the information 
I was interested in storing was only relevant to the view (i.e. which menu 
was opened when the user clicked on a link) and only meant for use in the 
view (reopen the menu that was opened at the time the user clicked).  It 
seems that I have now pushed knowledge of the view into the controller for 
an entirely arbitrary purpose.

On Friday, June 14, 2013 11:08:57 PM UTC+3, John wrote:
>
> Your view is there to produce HTML not manipulate data (other than to 
> display them). The proper MVC way is to do it in the controller and just 
> pass the required data to the view to render it.
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.




Saving session data from a view

2013-06-12 Thread David Suna
I am using CakePHP 1.3.  I have a helper which prints out the navigation 
menus.  Depending on which top level menu is selected the appropriate sub 
menu is displayed.  I want to be able to know on the next page view which 
menu / sub menu was previously displayed.  I thought to accomplish this by 
writing a session variable from my helper.  However, I am getting the error 
that session data cannot be written from a view.  Can anyone suggest an 
alternative way of accomplishing this?

I don't really understand why, if I can read Session information in the 
view, am I not able to write Session information in a view.

Pointers to appropriate resources or hints and tricks would also be 
appreciated.

Thanks.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

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




Re: How to delete an ACL node

2013-04-25 Thread david . suna
try 
cake acl help

You can delete either and aro or an aco using
cake acl delete aco 
or
cake acl delete aro 

I am using CakePHP 1.3 so I don't know if this has changed in the 2.x series

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

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




Re: Checking Consistency Before Saving

2013-04-23 Thread david . suna
I think a more basic question has to do with the data model.  Why are you 
duplicating information in two places?  If the Student has a reference to a 
Province and a Province has a reference to a Country then you do not need a 
reference to a Country in Student.

>From a UI standpoint I would allow the user to select a Country.  When the 
country is selected I would display only the Provinces that are defined for 
that Country.  When the Student is saved it would only save the 
province_id.  

If you need the country for the Student later on you can access it by doing 
a find with recursive set to 2 or by doing an explicit join of the Country 
table.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

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




Re: changing table fields value for all found in the list

2013-04-17 Thread david . suna
Yes you have to have "&" in front of $photo.  This makes $photo a reference 
to the element in $photos instead of a copy.  If you don't have it then you 
will be modifying a copy of the array element and not the element itself.

See http://www.php.net/manual/en/language.references.php for a discussion 
of references in PHP.

On Wednesday, April 17, 2013 12:28:58 PM UTC+3, Chris wrote:
>
> hi david,... 
> a quick question,... 
>
> do I have to have "&" upfront of $photo
>  in foreach ($photos as &$photo) 
> and what is it stand for..? 
>
> thanks 
> chris 
>
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

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




Re: changing table fields value for all found in the list

2013-04-15 Thread david . suna
You are doing a redirect inside of your loop which is kicking you out of 
your loop.  That is why only the first update works.

Also, there is no need to use the query method.  You would be better off 
looping through the returned items and setting the privacy field and then 
calling saveAll
i.e.
foreach ($photos as &$photo)
{
  $photo['Photo']['privacy'] = 2;
}
$this->Photo->saveAll($photos);

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

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




Re: find all users from another table

2013-04-15 Thread david . suna
Since you are calling find the first time with 'list' it is returning the 
array as you state.  However, you are trying to index into that array with 
an index of 'PhotoLike' which doesn't exist in that array.  So the error 
message is correct.

I believe that the second find should be 
find('all', array('conditions' => array('User.id' => $photo_likes)))

This should generate a WHERE clause of WHERE 'User.id' in (59, 48) which is 
what you want.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

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




Re: retrieving data in a view cake 1.3

2013-04-02 Thread david . suna
The easiest way to debug a problem like this is to set up a debugging 
environment (like NetBeans and XDebug see 
https://netbeans.org/kb/docs/php/debugging.html).  You can then set a break 
point at the point in the code and walk through and look at your data 
structures to see what is going on.

If you cannot set that up then you will need to do it the old fashioned way 
of printing out interim results and working from there.  Some questions to 
figure out are:

   1. Is $notes actually set in the view with the relevant data?  You can 
   do a print_r of $notes before the foreach and see what comes out.  If the 
   page is live you can do the print_r within a comment block in the HTML and 
   view source to see the results.
   2. Does $notes actually have an array which contains 'User' as an 
   associative element?
   3. Does the 'User' associative array have elements 'firstname', 
   'lastname' and 'username'
   4. Is there some control flow above the foreach which causes the entire 
   block of code to be skipped altogether?

Once you know the answers to these questions you can have a better idea as 
to what is causing the problem and potentially how to solve it.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

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




Re: Multiple Forms on the same form

2013-03-28 Thread david . suna
I have done this using AJAX.  Have the button fire an AJAX event which 
calls an action on your controller which returns an empty workcenter 
section of the field.  Pass in to the AJAX call an index and have the form 
fields specified using the index.  When the form is submitted you would 
then have an array of workcenters as part of your data and you can use 
saveAll to save the factory model and all related models (assuming you have 
set up a hasMany / belongsTo relationship between factory and workcenter).

Just remember that when editing a factory you will need to present all of 
the existing workcenters associated with it as well.

On Sunday, March 24, 2013 7:54:37 PM UTC+2, Steven Scaffidi wrote:
>
> Let's say I had a model called factory, and I wanted to add multiple 
> workcenters to the factory. When I go to add a new factory, I want a button 
> on the bottom of my form that says add workcenter. I want that button to be 
> always there just in case they want to add multiple work centers. I don't 
> want the form for workcenter to appear until they click the button add 
> workcenter. How can I accomplish this?
>
>
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

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




Re: Calling functions in other controllers

2013-02-27 Thread david . suna


On Wednesday, February 27, 2013 6:33:41 AM UTC+2, Yasir Arafat wrote:
>
> Hello,
> Before calling make sure you load the model of your cart model
> like
>
> $this->loadModel('Cart');
>
>
>
Since he is already including Cart in the $uses variable he does not need 
to call loadModel.

Also, the notation $this->Checkout->Cart is only relevant if the two models 
are related via an associate (i.e Checkout hasOne or hasMany Cart).  If the 
two models are not associated and the other model is loaded separately 
(either through $uses or through loadModel) then $this->Cart is the correct 
notation.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

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




Re: Calling functions in other controllers

2013-02-27 Thread david . suna
Sorry - noticed a couple of typos
1. The $uses variable indicates which other models this controller will use

2. you may need to find the cart you are looking for and pass that 
information into the total() call

On Wednesday, February 27, 2013 3:03:24 PM UTC+2, david...@gmail.com wrote:
>
>
> On Wednesday, February 27, 2013 2:55:53 AM UTC+2, lirc201 wrote:
>>
>> I'm in 2 different controllers.  In the checkout controller, I'm trying 
>> to call a function in the cart controller.
>>
>> Are you sure that the function is in the cart controller?  The $uses 
> variable indicates which other models this model will use (not which other 
> controllers).  If you want to call a method on another controller you will 
> need to use either App::Import or RequestAction.  If the error you are 
> getting is an SQL error rather than a method not found error it would seem 
> like the get() method is on the model.
>
> In general, many people will tell you that calling one controller from 
> another is a bad idea and should only be done as a last resort.
>
> If it is true that you are managing to call a controller method then it 
> may be simpler to move these methods into the Cart model which you would 
> then be able to access from the $uses variable.  
>
> If the methods are really on the model (or if you choose to move them 
> there) you will need to be acting on a particular instance of Cart so you 
> would do something like:
> $this->Cart->id = $CartID; // assumes you already have the id of the cart 
> you want
> $Cart = $this->Cart->get(); // assumes that the only state information 
> that get needs is the id and will read any additional information for itself
>
> Alternatively, you may need to find the cart you are looking for and pass 
> that information into the get call.  I.e.
> $Cart = $this->Cart->find('first', array('conditions' => 
> array('Cart.customer_id' => $CustomerID)));
> $Total = $this->Cart->total($Cart);
>
> As a side note:
> One debugging method you could use when confronted with this type of 
> situation is to copy and paste the query that generated the error directly 
> into something like PhpMyAdmin and see what part of the query is causing 
> the SQL error.  My guess is that in your case the query has a where clause 
> with 'WHERE Cart.id=' with no id specified or something like that.
>
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

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




Re: Calling functions in other controllers

2013-02-27 Thread david . suna

On Wednesday, February 27, 2013 2:55:53 AM UTC+2, lirc201 wrote:
>
> I'm in 2 different controllers.  In the checkout controller, I'm trying to 
> call a function in the cart controller.
>
> Are you sure that the function is in the cart controller?  The $uses 
variable indicates which other models this model will use (not which other 
controllers).  If you want to call a method on another controller you will 
need to use either App::Import or RequestAction.  If the error you are 
getting is an SQL error rather than a method not found error it would seem 
like the get() method is on the model.

In general, many people will tell you that calling one controller from 
another is a bad idea and should only be done as a last resort.

If it is true that you are managing to call a controller method then it may 
be simpler to move these methods into the Cart model which you would then 
be able to access from the $uses variable.  

If the methods are really on the model (or if you choose to move them 
there) you will need to be acting on a particular instance of Cart so you 
would do something like:
$this->Cart->id = $CartID; // assumes you already have the id of the cart 
you want
$Cart = $this->Cart->get(); // assumes that the only state information that 
get needs is the id and will read any additional information for itself

Alternatively, you may need to find the cart you are looking for and pass 
that information into the get call.  I.e.
$Cart = $this->Cart->find('first', array('conditions' => 
array('Cart.customer_id' => $CustomerID)));
$Total = $this->Cart->total($Cart);

As a side note:
One debugging method you could use when confronted with this type of 
situation is to copy and paste the query that generated the error directly 
into something like PhpMyAdmin and see what part of the query is causing 
the SQL error.  My guess is that in your case the query has a where clause 
with 'WHERE Cart.id=' with no id specified or something like that.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

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




Re: Problem with using components when Importing a Controller

2013-02-21 Thread david . suna


On Thursday, February 21, 2013 2:20:00 PM UTC+2, euromark wrote:
>
> Even with Cake1.3 you dont import and abuse controllers this way.
> You need to refactor those controller methods into clean model methods and 
> only re-use those.
>

Since we are talking about sending e-mails which uses the Email component 
the only options are to abuse controllers or models (as models are not 
supposed to use components).  I can try moving the code into the model and 
using App::Import to get the Email component and see if it is set up 
correctly that way.  I have a work around as I showed in the code I 
included originally so I don't have a lot of incentive to reorganize the 
code now.

The primary question is, if you have a facility like App::Import shouldn't 
the result be fully functional?

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

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




Problem with using components when Importing a Controller

2013-02-21 Thread david . suna
I have a controller EmailNotifications which I am accessing using 
App::Import('Controller', 'EmailNotifications');

The EmailNotifications controller uses the Email component
  var $components = array('Email', 'RequestHandler');

When I import the controller I use the following code:
// Load the Email Notification controller
App::Import('Controller', 'EmailNotifications');
$EmailNotification = new EmailNotificationsController();
$EmailNotification->constructClasses();

Inside of the notify method of the EmailNotificationsController I use the 
Email component
  $this->Email->reset();
  $this->Email->to = $Notify['EmailNotification']['email_address'];
  $this->Email->subject = ucwords("$Subject ($Activity)");
  $this->Email->replyTo = $Notify['EmailNotification']['email_address'];
  $this->Email->from = $Notify['EmailNotification']['email_address'];
  $this->Email->template = $Template;
  $this->Email->sendAs = 'text';
  // Since this is being used via App::Import the Controller is not 
properly set
  // so we set it here
  $this->Email->Controller = $this;
  $Ret = $this->Email->send();

If I do not manually set $this->Email->Controller = $this before calling 
send the variables I have set earlier in the code are not exported to the 
email view.

>From reading the manual I understood that calling constructClasses would 
initialize any models and components used by the controller.  However, the 
components do not seem to be initialized correctly.

Is there something else I am supposed to do in order for this to work 
correctly?  Is this a bug?  I am using CakePHP 1.3.10

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

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




Re: Implementing the Event Notifier Pattern in CakePHP

2013-02-20 Thread david . suna


On Wednesday, February 20, 2013 2:05:49 AM UTC+2, cricket wrote:
>
>
> Better to implement this in a component ... as long as your events 
> will always be triggered from within a controller. That is, you won't 
> be calling it in an afterDelete() callback. From the controller: 
>
> $this->Notifier->send('ModelName', ...); 
>
> Or, maybe pass it a keyed array. In any case, better as a component, imho. 
>

The manual says "To access/use a model in a component is not generally 
recommended" and this will need to access several models (at least the 
EmailNotification model to determine who to send to as well as other models 
to map the specific instance of the updated model to a particular client).

What is the advantage of a component over the other alternatives I raised?

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

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




Implementing the Event Notifier Pattern in CakePHP

2013-02-19 Thread david . suna
Does anyone have any advice as to how to go about implementing the Event 
Notifier pattern in CakePHP 1.3?

Basically, I want to have email notifications sent out when various events 
occur (adding or deleting instances of specific models).  The notifications 
can be sent to different e-mail addresses depending on the model that the 
event occurred on and whether the notification is being sent to the system 
administrator or to a client specific administrator.

To this end I implemented a model called EmailNotification which has the 
client id (0 for system admin), the model to be monitored and the email 
address for the notifications to be sent to.

I would have the models being monitored make a common call with the 
necessary information for the notification email to be sent out.  It would 
be the responsibility of this code to look up who the notification should 
be sent to and to send it out.

My current thought is to have a method on the 
EmailNotificationsController->notify that would be called by the 
controllers of the models being monitored using requestAction.

Alternatively, I could load the EmailNotificationsController using 
App::import and call the method directly from the monitored model's 
controller.

Or is there a better way to implement this?

Thanks.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

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




Re: Only check beforeDelete if direct deletion

2013-02-19 Thread david . suna

On Monday, February 18, 2013 12:27:46 AM UTC+2, cricket wrote:
>
>
> Perhaps you need to re-think your schema. What is the purpose of Record? 
>
> Also, why do you wish to cancel a Record delete if an Invoice exists? 
>

I abstracted the specific problem domain in the hopes of not getting lost 
in the details.
A Record represents a Tenant call with a bunch of associated data.  If an 
Invoice references a Record then the requirements of the system are that 
the view on Invoice needs to be able to display the information from the 
Record.  In addition, the business logic for handling an invoice needs to 
handle cases of Invoices with a Record (using some of the data from the 
Record) and Invoices without a record.  If a Record is deleted that is 
referenced by an Invoice then the data integrity is broken.

Rather than get into the specifics of the problem domain I am more 
interested in the CakePHP issues.

>From reading through the CakePHP code it seems like calling delete on the 
top level model will call deleteAll on a hasMany related model if 
"exclusive" is set in the relationship.  deleteAll has three parameters.  
The third is $callbacks which is set to false by default.  Since deleteAll 
is called by the top level model with only one parameter that would mean 
that the call backs would not be called and the problem I described would 
not happen.  I don't know if that is the intention of the "exclusive" 
attribute as the documentation just says that it means deleteAll is 
called.  But it seems to address my issue.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

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




Re: Only check beforeDelete if direct deletion

2013-02-17 Thread david . suna
Unfortunately, that won't work since an Invoice does not always have a 
Record.  I still need to be able to get all of the Invoices for a Tenant 
even if there is no Record associated with the Invoice.  Similarly, there 
can be Records that are not referenced by an Invoice.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

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




Only check beforeDelete if direct deletion

2013-02-17 Thread david . suna
I have an application built with CakePHP 1.3 with a model structure as 
follows:
Tenant hasMany Records (dependent => true)
Tenant hasMany Invoices (dependent => true)

An Invoice can have a reference to a Record which I represent as
Invoices belongsTo Records
so that fetching an Invoice will fetch the associated Record (if there is 
one)

In the Records model I have a beforeDelete method which checks that no 
Invoice references this record before deleting it.

This all works fine.  The potential problem I am considering is if I delete 
a Tenant it will cascade to delete all Records and Invoices associated with 
it.  Since I don't control the order in which the related models will be 
deleted it would be possible that the Records would be cascaded first and 
fail the beforeDelete method because of existing Invoices that reference 
the record ultimately failing the entire delete operation.  However, since 
the entire tenant is being deleted I do not want to enforce the constraint 
of not deleting a record if an invoice references it allowing the delete to 
complete regardless of the order that the associated models are deleted.

My questions are:
1. Do I have to worry about this?  I have not been able to produce the 
problem but it seems theoretically possible.
2. If I do have to worry about this scenario, is there a way to distinguish 
in the beforeDelete call whether this deleting is a direct deletion or a 
cascade from the Tenant deletion?  If I can do that then I would be able to 
add a condition to only enforce the constraint if this is a direct delete.
3. Is there a better way of representing this relationship that would not 
run into this problem?

Thanks

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

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




Re: Can not save two fields

2013-02-06 Thread david . suna
What is the SQL that is generated from the save function?

Do you have a debugging environment set up so you can step through the code?

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

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




Re: $useDbConfig being ignored in 1.3.10

2013-01-28 Thread david . suna
I figured out what the problem was.  I had misnamed the model file so the 
file was being ignored and the defaults were being used for the model 
instead.  I renamed the model file correctly and now it is working.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

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




$useDbConfig being ignored in 1.3.10

2013-01-28 Thread david . suna
I have an app that was developed using CakePHP 1.3.10.  I am now trying to 
add a controller for a model that is in a different database.  The code for 
the model is very simple:

class Cdrs extends AppModel
{
  /**
   *
   * @var string The name of the model
   */
  var $name = 'Cdrs';

  /**
   *
   * @var string Alternate database connection information for this model
   */
  var $useDbConfig = 'otherdb';

  /**
   *
   * @var string The name of the table for this model
   */
  var $useTable = 'cdrs';
}

In database.php I added in otherdb as follows:
class DATABASE_CONFIG {

var $default = array(
'driver' => 'mysql',
'persistent' => false,
'host' => 'localhost',
'login' => 'user1',
'password' => 'password1',
'database' => 'db1',
'prefix' => '',
);

var $otherdb = array(
'driver' => 'mysql',
'persistent' => false,
'host' => 'localhost',
'login' => 'user2',
'password' => 'password2',
'database' => 'db2',
'prefix' => '',
);

var $test = array(
'driver' => 'mysql',
'persistent' => false,
'host' => 'localhost',
'login' => 'user',
'password' => 'password',
'database' => 'test_database_name',
'prefix' => '',
);
}

However, the controller is giving me the error 
*Error: * Database table *cdrs* for model *Cdr* was not found.

When I step through the code in the debugger I see the following stack trace
cake/libs/model/model.php.Model->setDataSource:2831
cake/libs/model/model.php.Model->__construct:469
cake/libs/class_registry.php.ClassRegistry->init:150
cake/libs/controller/controller.php.Controller->loadModel:637
cake/libs/controller/controller.php.Controller->constructClasses:502
cake/dispatcher.php.Dispatcher->_invoke:186
cake/dispatcher.php.Dispatcher->dispatch:171
app/webroot/index.php.{main}:83

The $dataSource being passed in to setDataSource is "default" instead of 
"otherdb"
If I change the value in the debugger to "otherdb" then the error goes away.

Why is the $useDbConfig being ignored?  What am I doing wrong?

Is it possible that this was a bug that was fixed in a later version of 
1.3?  I can probably upgrade within 1.3 if necessary but I cannot upgrade 
to 2.x at this point in the development process.

Any help would be appreciated.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
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.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Multiple domains sharing a single database with non-unique user names

2013-01-16 Thread david . suna
I have a Cake 1.3 application that we have been developing for a while.  
The application will support multiple domains and sub domains on a single 
database.  We are using the standard ACL for user login and permissions.  
The problem that we have run in to is that the user name space is not 
unique across domains and sub domains.  For example, there could be a user 
jack on sub.domain1.com and another user jack on sub2.domain1.com or a user 
jack on sub1.domain2.com.  There is another table that contains the 
relationship between users and sub domains / domains using the user_id 
field in a belongsTo relationship. Since the username column in the users 
table must be unique this is problematic.  For now we have come up with two 
approaches.  

The first is to change the username to j...@sub.domain1.com.  This makes 
the username unique.  However, it is cumbersome for the user since they are 
going to a url which is sub.domain.com/login already.  Also, it would be a 
problem if the sub domain name is ever changed since all of the usernames 
would contain the old sub domain name.  

The other alternative is to change the users table to a view that does a 
join on a shadow users table and the fully qualified domain name.  The 
problem with this is that it needs to be an updatable view to allow for 
updating passwords and the requirements in MySQL for an updateable view 
seem rather restrictive.  We wouldn't want a change to either of the 
underlying tables to break the login process inadvertently.

The other wrinkle to add in to the mix is that there are some users (system 
administrators) that are not associated with a sub domain / domain so we 
need to support them logging in as well.

For now we are going with the first approach under the assumption that the 
downsides of that approach are less severe.  However, I wanted to know if 
anyone else has dealt with this type of configuration and found a better 
alternative.

Thanks.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
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.
Visit this group at http://groups.google.com/group/cake-php?hl=en.