Re: Would PHP 5.3 stop cake cron job working?

2012-03-27 Thread LunarDraco
Without a bit more detail, I would guess that the new PHP 5.3 does not
have mail setup by default and from a hosting service this usually
requires a request before they will enable it.
You can check that if you have ssh access to the server console by
inspecting the php.ini
Look for the setting for mail or smtp.

You should also see some messages in the log file for php/apache
indicating the function you are trying to use is unavailable or not
defined.


On Mar 26, 10:51 am, sarahlou  wrote:
> I have a site (originally built back in 2009) with a couple of cron
> jobs for order notification emails. The site is running CakePHP
> version 1.2.4.8284
>
> After the hosting server was upgraded to PHP 5.3, the cron jobs appear
> to have stopped working (they still run, but no email is sent). The
> website itself is still functioning ok.
>
> Is this likely to be a conflict between the Cake version & PHP 5.3.
> Does anyone have any advice as to the best way around this?
>
> Many thanks,
>
> Sarah

-- 
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: High scalability with CakePHP

2012-02-09 Thread LunarDraco
Cakephp is a framework built on top of PHP. There is really nothing
all that special about Cakephp when it comes to scaling your site.
The basic techniques of scaling a web application for a LAMP stack are
the same weather or not your using Cakephp.
Change your search and leave out the 'cakephp' keyword and look at
articles that talk about scaling a LAMP stack.

Then take those individual techniques of memcache, NFS, CDN, Database
Replication, Session mgt, etc. And look for articles that talk about
each of the specific techniques in regards to Cakephp. And even then
the techniques often times have nothing to do with Cakephp. You'll
find much more relevant information and having a good overview
understanding of scaling a basic LAMP stack will help you understand
more about what area of your application needs to be most scalable.

For an example it makes no sense to add multiple servers if the
problem could be better resolved by simply doubling the memory in your
current server.
This is where performance profiling really pays off. You need to know
what your bottle necks are, and you need to know what the correct
solution to that bottle neck will be. There is no one size fits all
scalability plan. But there are specific techniques to deal with a
specific problem.
Understanding what the field of scalability has to offer for your
underlying technologies is key to being successful in solving your
bottlenecks.


On Feb 9, 1:57 am, byqsri  wrote:
> Many Thanks for your answers.
> It seems to me that you have experience with how scale a cakephp
> system
>
> About DB : I have find this to configure Master and 
> Slaveshttp://bakery.cakephp.org/articles/gman.php/2009/01/20/master-slave-s
> But it seems very simple perhaps there is some hidden complications.
> Another question about this : What is the best practise to replicate
> the data instantly from Master to Slaves when there is a write
> operation?
>
> About CakePHP : What is the best practise to deploy the cakephp code
> updates on many servers instantly? Rsync?
> Exists a configurable automatic tool to do this?
>
> Many Thanks
>
> On 8 Feb, 17:05, Justin Edwards  wrote:
>
>
>
>
>
>
>
> > If your concern is bandwidth, host all of your static files on a CDN.
>
> > If your concern is processing power, distribute your load through many
> > servers (you can use a load balancer, apache, lighttpd, nginx or cherokee)
> > and use mysql or a cache backend for your session storage.
>
> > If your concern is database usage (IO), cache most of your data (memcached
> > would be the best here).  You can also use a master and slave database
> > setup.  Make all of your reads from your slave and your writes to your
> > master.
>
> > If you distribute your load between servers, you will need to make sure
> > files are synchronized,  If you have file upload you need to make sure that
> > you force users to upload to one server and then rsync your data out from
> > that server to your others.
>
> > You can also host your data off of an NFS mount so that you don't need to
> > synchronize your data.
>
> > On Wed, Feb 8, 2012 at 9:03 AM, byqsri  wrote:
> > > Hi
> > > I have a web application where users can uplaod file,images and work
> > > with some datas in db
> > > I use CakePHP ,MySQL,Memcache.
> > > I have a server with Apache and for the file's uploading ( I use Media
> > > Plugin of David Persson).
> > > I have another server with MySQL
> > > For the moment I have 500 users and all works fine.
> > > My problem is that in the next months I can have a very fast increment
> > > of users and this configuration is not  sufficient for me.
> > > I have tried to search on Google about how scaling a web app with
> > > CakePHP with scaling of MySql and scaling CDN  but I didn't find
> > > anything really concrete I would ask if someone with experience about
> > > this if he can suggest to me something resources (books,articles,code
> > > suggestions) ffrom which I can begin  to work.
> > > Many Thanks
>
> > > --
> > > Our newest site for the community: CakePHP Video Tutorials
> > >http://tv.cakephp.org
> > > Check out the new CakePHP Questions sitehttp://ask.cakephp.organdhelp
> > > others with their CakePHP related questions.
>
> > > To unsubscribe from this group, send email to
> > > cake-php+unsubscr...@googlegroups.com For more options, visit this group
> > > athttp://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video 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 about using real HTML templates for Form input fields?

2011-11-03 Thread LunarDraco
In 2.0 you solve this tedious by building/subclassing formhelper.
Using the alias feature and writing your own functions to support your
needed/different template and format.

On Nov 3, 7:47 pm, Miles J  wrote:
> Ive always wanted this. Cakes defaults are pretty handy but once you
> want to break out of the norm it gets tedious.
>
> I would also change the HTML structure but thats just me :P
>
> @Sherlock - There's not much overhead in doing a basic PHP include.
>
> On Nov 3, 6:21 pm, 100rk  wrote:
>
>
>
> > > Those templates could be "theme" specific (like Twitter Bootstrap) and
>
> > IMHO only not-so-easy solvable problem with Twitter Bootstrap and cake
> > forms is - label wrapped around checkboxes, for both single-ones and
> > 'multiple' (wrapped in unordered lists). Rest of it is easy, thanks to
> > 'className' key in $helpers and custom aliased YourFormHelper (and
> > probably also YourHtmlHelper with either customized $_tags property or
> > using 'configFile' configuration setting and proper config file with
> > customized and/or added tags in it) where you can inject/set classes/
> > divs etc before call of parent class (FormHelper) methods.o

-- 
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: DebugKit in 2.0

2011-10-30 Thread LunarDraco
As the App::import no longer recursively scans the sub directories you
need to be specific about the path for FireCake to load.
Both of these worked for my setup where DebugKit is installed in the
main "Plugin" folder
App::import('Lib', 'DebugKit.FireCake');
App::import('Lib', 'DebugKit.FireCake', array('file' =>
'Plugin'.DS.'DebugKit'.DS.'Lib'.DS.'FireCake.php'));

This one did NOT work with my setup: App::import('Vendor',
'DebugKit.FireCake');

This was a clean install of (FireFox, FireBug and FirePHP) and I had
forgot to enable FirePHP from the tools menu. Spent a bit of time on
that because it looks like its loaded and working when you look at
FireBug. But without the FirePHP->enabled checked the UserAgent sent
to the server does not contain the FirePHP version. When FireCake.php
does a check to see if its enabled via the UserAgent version, its
missing, and exits early.

On Oct 30, 5:01 am, Jeremy Burns | Class Outfit
 wrote:
> Worked perfectly thanks (although I had also commented the component out of 
> my AppController, which stumped me for a few moments):
>
> public $components = array('DebugKit.Toolbar');
>
> Jeremy Burns
> Class Outfit
>
> http://www.classoutfit.com
>
> On 30 Oct 2011, at 06:04, LunarDraco wrote:
>
>
>
>
>
>
>
> > I was able to get DebugKit working by
> > cd to Plugins
> > git clonehttps://github.com/cakephp/debug_kit.gitDebugKit
> > After I had a copy I cd into the DebugKit folder then I switched to
> > the 2.0 via
> > git checkout 2.0
> > Updating bootstrap.php to load the plugin (new CakePHP 2.0
> > requirement):
> > CakePlugin::load('DebugKit');
>
> > Modified the View/Layouts/default.ctp by commenting out the following
> > line
> > element('sql_dump'); ?>
>
> > I've got DebugKit working but I'm struggling with DebugKit.FireCake
> > I'm sure it something to do with the changes to App::Import vs
> > App::uses and the App::build paths.
>
> > Morgan
>
> > On Oct 29, 11:16 pm, Jeremy Burns  wrote:
> >> Anyone got any tips for getting DebugKit working in 2.0? I've run the
> >> upgrade script over it and am loading it in bootstrap.
>
> > --
> > Our newest site for the community: CakePHP Video 
> > Tutorialshttp://tv.cakephp.org
> > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help 
> > others with their CakePHP related questions.
>
> > To unsubscribe from this group, send email to
> > cake-php+unsubscr...@googlegroups.com For more options, visit this group 
> > athttp://groups.google.com/group/cake-php

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


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


Re: DebugKit in 2.0

2011-10-29 Thread LunarDraco
I was able to get DebugKit working by
cd to Plugins
git clone https://github.com/cakephp/debug_kit.git DebugKit
After I had a copy I cd into the DebugKit folder then I switched to
the 2.0 via
git checkout 2.0
Updating bootstrap.php to load the plugin (new CakePHP 2.0
requirement):
CakePlugin::load('DebugKit');

Modified the View/Layouts/default.ctp by commenting out the following
line
element('sql_dump'); ?>

I've got DebugKit working but I'm struggling with DebugKit.FireCake
I'm sure it something to do with the changes to App::Import vs
App::uses and the App::build paths.

Morgan

On Oct 29, 11:16 pm, Jeremy Burns  wrote:
> Anyone got any tips for getting DebugKit working in 2.0? I've run the
> upgrade script over it and am loading it in bootstrap.

-- 
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: Using mPDF

2011-09-09 Thread LunarDraco
You might want to review this article in the bakery:
http://bakery.cakephp.org/articles/Casmo/2010/06/26/creating-pdf-files-with-html2ps-html2pdf

As mPDF is based on html2fpdf perhaps the techniques in that article
could help you get started.

On Sep 8, 12:34 pm, Uziel Barbosa  wrote:
> anyone?
>
> 2011/9/8 Uziel Barbosa 
>
> > Has anyone used mPDF with Cake?
> > Thanks.
>
> > __
> > Uziel Barbosa
> > GodLabs
> > IFAL
> > @uzielbarbosa
>
> --
> Uziel Barbosa
> GodLabs
> IFAL
> @uzielbarbosa

-- 
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: Issues With Auth Component

2011-09-08 Thread LunarDraco
> > Auth is NOT Access Control, It is simply authentication.
>
> No need to go rushing towards ACL.
>
> http://book.cakephp.org/view/1275/authorize
>
> $this->Auth->authorize = 'controller'; is a very acceptable
> configuration for authorisation, hence why it is probably the most
> commonly used.
>
> I find ACL overkill for most situations and many other people at
> CakeFest felt the same, although in the interests of fairness, a lot
> of people also confirmed they use ACL all the time.
I agree with Paul, I actually don't use ACL on any of my projects as
the authorize by controller action is sufficient for my projects and
easier to maintain. I should have been clearer on my comment of "if
you don't really need full ACL". Thanks for pointing out the book ref.

Morgan

-- 
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: 'Site under maintenance' option

2011-09-08 Thread LunarDraco
You could restrict it by client ip so that only the blessed ones can
connect from a specific set of ip's to the login page.
Then you don't have to worry about a secret url you can do the check
on the client ip in App_controller and allow/deny and redirect with
normal cake process before they ever see the login page. Post a note
on the Login page so other admins who are allowed to see the login
because they meet the special ip's know the site is in maintenance
mode.

If you do this I would also only allow admins who are connected from
the specific set of ip's to set the site to maintenance mode. Or on
the page to set the site to maintenance mode allow adding the current
client ip as a valid connection site.

It would suck to have to drive into the office because you set the
site to maintenance mode while connected from an ip that wouldn't let
you login to turn maintenance back off.


On Sep 7, 9:30 am, Xoubaman  wrote:
> I want that, when site is disabled, nobody will reach the login form
> whatever they do, unless the blessed ones who know the secret-and-only-path
> to do so. If everytime an user try to do some action that requires to be
> logged in, he's redirected to log in screen, the site won't look really
> disabled.
>
> The disabled boolean is read from database and loaded by a configuration
> helper (WebThecnick configuration plugin), that loads configuration values
> at the very beginning of AppController::beforeFilter, so secret route won't
> be available at routes.php.

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


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


Re: How to work in a group with Git and remote server? (Ex. Keep files in sync while FTP'ing)

2011-09-08 Thread LunarDraco
Git does a great job of keeping network traffic to a minimum.
So I use git from my live hosted site (remote server) to pull a
specific tag. This way if something goes wrong or some bad code ended
up in the release I can always easily and quickly pull the previous
version tag until the problem is corrected. Most hosting sites servers
support the git client. And most will allow you ssh connection if you
request it.

I've found the following post and workflow from Vincent to be a great
baseline of how a team should work together using git.
It has a nice diagram and the blog entry covers all of the important
process for the entire development cycle.

http://nvie.com/posts/a-successful-git-branching-model/

You don't have to use all of his suggestions but the diagram really
helps you see how they all work together over time and versions of a
project.

Maybe git isn't directly related to cake-php and some have mentioned
this to be off topic. But just like the databases are not directly
cake-php our apps are useless without them. I view a source repository
as very on topic as I can't imagine working on any project without a
source repository or a deployment plan.


On Sep 7, 12:42 pm, andrewperk  wrote:
> Hello,
>
> I'm wondering how to keep my cake files in sync while working in a
> group with others. I understand how to use git and I've been using it
> solo for versioning my applications. Then I just use Filezilla to FTP
> my files into my remote server.
>
> This will be difficult to do in a group though as I'll have to
> download the whole framework from the server each time before making
> new changes to  ensure that I have the most recent changed files from
> my partners.
>
> How can I make it so we can all work remotely in different places on
> the same project and only have to upload/download to/from the server
> the most recently changed files.

-- 
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: Issues With Auth Component

2011-09-06 Thread LunarDraco
Auth is NOT Access Control, It is simply authentication. You know the
user is real and has validated.

Access Control at a data level requires a bit more than Auth.

In general you can build up ACL (Access Control List) where you can
then control which data is visible to different request objects.

If you really don't need full ACL and you just want to limit the user
you can add a check against the Auth components current User id and
compare to the id they are trying to edit/view etc.
$this->Auth->user('id');

More info can be found here: 
http://book.cakephp.org/view/1242/Access-Control-Lists


On Sep 2, 12:55 pm, tubiz  wrote:
> I have already setup the auth component and it is working perfectly.
> But I just discovered a problem.
> There are two users in my users table when I am login as one of the
> users I can access the other users details just by changing the i.d.
> This wouldnt be secure as a login user can access all the details of
> other users,
> Please how can I stop this so that a logged in user is only able to
> view his details only and not other users 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: Accessing another controllers function.

2011-08-16 Thread LunarDraco
You should push your report code to your models. Your Domains
controller will have good visibility to both the Domains model as well
as the Locations model.


On Aug 15, 3:03 pm, Michael Gaiser  wrote:
> So I have 2 controllers. Domain, & Location. Domains have several
> locations. The Location controller has a function called "report"
> which I want to be able to call from my domain controller to generate
> the reports for each of its locations. I was thinking that I could
> just do it like this:
> $report = $this->Domain->Locations->report($id)
>
> But that doesn't seem to work. Is there a way to do this or is my
> thinking backwards on this one? Thanks.
>
> ~Michael

-- 
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: Where should i contact right people in CakePHP.org because this security critical problem

2011-06-30 Thread LunarDraco
I'm curious why your blaming CakePHP for MySql allowing connections
outside of the webserver?

I made this error once on a live site. Someone hacked my sight
connected to the db and deleted everything in the tables.
When this happened I didn't go off and blame CakePHP or even MySql. I
knew I was the one responsible for the security of that site.
You could just as easily blame MySql for allowing you to configure a
connection from outside your network.

I changed the user credentials to a specific user (not root) and
password to the db and restricted Mysql to only accept connections
from the webserver for that user. I added a sandbox.php to my
configurations. My app/config/sandbox.php is NOT checked into the
repository and it holds custom configuration for the local system. So
on my dev machine I have some specific settings and for the live
deployment I have a different set of settings. It also enables
multiple developers to have completely separate configurations and not
effect the structure in source repository. This sandbox file is loaded
via Configure::load('sandbox'); at the top of core.php and used as in
Configure::write('debug', Configure::read('Sandbox.debug'));

I don't remember exactly where the concept of using a sandbox.php file
and Configure::load() came from (I think it was in one of the many
articles from one of the core devs) but the credit for this technique
belongs to them and is probably why the function is already in the
Configure class in the first place.

I've thought about using getReferer or $_SERVER['SERVER_NAME'] as part
of the sandbox file name which would allow me to do local testing on
the live server but have yet to implement that. You would create
multiple sandbox files as in mysite_com_sandbox.php and
127_0_0_1_sandbox.php

Overall I'm with Mark. If we as a community want those changes we need
to strengthen our understanding of that code and submit a patch. As
for me I've learned my lesson, I have a great solution that works
great with the current code base and solves a few additional problems
I was having with multiple developers and deploying new changes to the
server. These are very simple to setup and make a part of your
deployment process.

-Morgan

-- 
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: Anyway to change the default.ctp to another header.ctp ?

2011-04-19 Thread LunarDraco
Not sure if your example given for the login was where you intend on
using this.

I would leave the default.ctp as the main header for your site.
Create a special/custom header for your auth/login/register pages.
Something like login.ctp
Then as Chris mentions set $this->layout = 'login"; in the actions of
your auth or user controller for the login and register actions.

You can change set $this->layout from anywhere in the controller.

http://book.cakephp.org/view/1287/Setting-up-the-Layouts

On Apr 18, 3:13 am, chris  wrote:
> You could use this to change to a different layout file in the
> beforeFilter() method of your app_controller.php file
>
> $this->layout = 'loggedin';
>
> and create a loggedin.ctp file in your layouts directory. This file
> can then look complety different to default.ctp
>
> I have a few different layouts setup dependant on different user types
> I have setup in my application, and switch between them in
> beforeFilter.
>
> On Apr 17, 9:36 am, Chuck  wrote:
>
>
>
>
>
>
>
> > thanks!
>
> > Chuck
>
> > On Apr 17, 4:13 am, "Krissy Masters" 
> > wrote:
>
> > > You could have an if or switch block in the layout to echo an element
>
> > > if($logged_in){
>
> > > echo $this->Element('private_header, array());
>
> > > //1 element header
>
> > > } else {
>
> > > //other header element
> > > echo $this->Element('public_header, array());
>
> > > }
>
> > > K
>
> > > -Original Message-
> > > From: cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] On 
> > > Behalf
>
> > > Of Chuck
> > > Sent: Saturday, April 16, 2011 5:23 PM
> > > To: CakePHP
> > > Subject: Anyway to change thedefault.ctpto another header.ctp ?
>
> > > I know this might sound kinda noob.  As I observed, cakephp uses view/
> > > layout/default.ctpas the header and footer.  If I click go to another
> > > page, is there anyway I could use another header instead ofdefault.ctp? 
> > > For example, say I want to change the header completely
> > > after logging in. Anyone point me to the right direction? thanks.
>
> > > Chuck.
>
> > > --
> > > Our newest site for the community: CakePHP Video 
> > > Tutorialshttp://tv.cakephp.org
> > > Check out the new CakePHP Questions sitehttp://ask.cakephp.organdhelp
> > > others with their CakePHP related questions.
>
> > > To unsubscribe from this group, send email to
> > > cake-php+unsubscr...@googlegroups.com For more options, visit this group 
> > > athttp://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video 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: I want to use textbox to display datetime fileld instead of drodown lists.

2011-04-12 Thread LunarDraco
I remembered that I originally found this in a bakery article. So
credit for this date picker mashup goes to mmanning.

The article is based on an earlier version of the Unobtrusive Date
Picker. There were some significant design changes with the latest v5
which is the version my rough sample was built on.

For your further reading pleasure.
http://bakery.cakephp.org/articles/mmanning/2008/04/12/using-the-unobtrusive-date-picker-widget-in-cakephp

-- 
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: You favorite IDE/ Dev Setup?

2011-04-01 Thread LunarDraco
I ride a RoadStar Motorcycle.

When it comes to which ide/tools you use its about as relevant as what
kind of car do you drive to work.
The biggest factor is personal preference, and experience with the
tools. Second I don't just develop php, I also work with css html
javascript, java, os scripting weather it be bat files for the windows
or shell script and python on linux.
I use various editors. But mostly eclipse.


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


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


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

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

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

Sarcasm was intended.

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

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

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

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

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

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

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


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


Re: Cakephp 1.3 Form Helper inputDefaults bug?

2011-02-18 Thread LunarDraco
Just an FYI, I've experienced situations like this where Firebug and
the View Source seems so different.
Everytime I've seen this I've missed placing a closing tag or forgot
to include a required wrapping tag. As an example I had forgot a 
so my 's were not conained correctly.
Not sure which one (firefox or firebug) does it but one of them tries
its best to correct the html so the data can be displayed.

I'd look for a missing ending tag or invalid structure in your output
before you send it to the browser, could be in your layout or how you
generate the view.
I know the Html helper has caught me a few times on div and spans as
one format to the $this->Html->div() will return a fully closed tag
and one format will only return the open tag and you need to close it
off in a separate call.

On Feb 17, 12:03 pm, "designv...@gmail.com" 
wrote:
> In case anyone finds this:
>
> Here's how to change the error message container:
>
> http://book.cakephp.org/view/1401/options-error
>
> And an example:
>
> Form->create('Artist', array('inputDefaults'
> =>array('div' => array('tag' => 'p'),'between' => '','error' =>
> array('wrap' => 'span', 'class' => 'bzzz'),'format' =>array('before',
> 'label', 'error', 'between', 'input', 'after'; ?>
>
> On Feb 17, 4:42 pm, "designv...@gmail.com" 
> wrote:
>
>
>
>
>
>
>
> > So that seems to be the issue lord alone knows why
>
> > Does anyone know how to change the div to a span for the validation
> > errors? ;-)
>
> > d//t
>
> > On Feb 17, 4:32 pm, "designv...@gmail.com" 
> > wrote:
>
> > > Ahh wierd... i was viewing the HTML in Firebug and it was messed up,
> > > actually view source in Firefox and its correct...
>
> > > Hmmm...
>
> > > (and I know I shouldn't be putting divs inside p tags! hehe)
>
> > > On Feb 17, 4:27 pm, Jeremy Burns | Class Outfit
>
> > >  wrote:
> > > > Could it be browser behaviour because p is a block level element?
>
> > > > Jeremy Burns
> > > > Class Outfit
>
> > > > jeremybu...@classoutfit.comhttp://www.classoutfit.com
>
> > > > On 17 Feb 2011, at 16:20, designv...@gmail.com wrote:
>
> > > > > Hi there,
>
> > > > > When using the 'inputDefaults' option in Form->create and doing the
> > > > > following:
>
> > > > > Form->create('Enquiry', array('inputDefaults' =>
> > > > > array('div' => array('tag' => 'p'),'between' => '','format' =>
> > > > > array('before', 'label', 'error', 'between', 'input', 'after'; ?>
>
> > > > > Cake seems to close the  tag imediately after the label, however if
> > > > > I remove this it defaults using a div that surrounds everything.
>
> > > > > I would have thought that specifying using a P tag instead would still
> > > > > act the same...
>
> > > > > Anyone noticed this?
>
> > > > > d//t
>
> > > > > --
> > > > > Our newest site for the community: CakePHP Video 
> > > > > Tutorialshttp://tv.cakephp.org
> > > > > Check out the new CakePHP Questions 
> > > > > sitehttp://ask.cakephp.organdhelpotherswith their CakePHP related 
> > > > > questions.
>
> > > > > To unsubscribe from this group, send email to
> > > > > cake-php+unsubscr...@googlegroups.com For more options, visit this 
> > > > > group athttp://groups.google.com/group/cake-php

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


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


Re: Adding fields to a form dynamically - a complex case

2011-02-16 Thread LunarDraco
I do the very same thing with a contacts hasMany addresses and a
contacts hasMany phones type relations
The form uses some simple scriptaculous/prototype javascript. To
duplicate and insert an html template set to display=none. It changes
the display and updates the field id's each time the "add" button is
clicked.
This builds the form controls in a cakephp freindly way so I can call
SaveAll. In my model beforeSave I strip out any data items that are
still in the template format.

I took a glance at the link Dwayne provided and it looks to be fairly
complete I might replace what I have with his as mine is more of a one
off solution in its current state.
I thought I would share it as it may give you some other ideas of
implementation and integrating the dynamicField solution into the
CakePHP form.

In my view I have the following div's The first one is the Template
and is hidden the second div is visible and by defaults automatically
shows the Phones associated with the Contact.






Optout



Work
Home
Mobile
Home 
Fax
Work 
Fax
Pager
Other


remove


div('contact-phones');
if(!empty($this->data['Phone'])){
$phones = $this->data['Phone'];
foreach ($phones as $i=>$phone){
echo '';
echo $form->input('Phone.'.$i.'.id');
echo $form->input('Phone.'.
$i.'.optout',array('div'=>false,'before'=>'','after'=>''));
echo $form->input('Phone.'.
$i.'.deleted',array('type'=>'hidden','value'=>'false'));
echo $form->input('Phone.'.
$i.'.value',array('label'=>false,'div'=>false,'before'=>'','after'=>''));
echo $form->input('Phone.'.
$i.'.label',array('options'=>array('Work'=>'Work','Home'=>'Home','Mobile'=>'Mobile','Home
Fax'=>'Home Fax','Work Fax'=>'Work
Fax','Pager'=>'Pager','Other'=>'Other'),'label'=>false,'div'=>false,'before'=>'','after'=>''));
echo 'remove';
echo '';
}
}
echo $ajax->divEnd('contact-phones');
?>



The JavaScript first finds the max phone iteration. It grabs a copy of
the 'contactPhoneTemplate' updates the id's and name values and then
inserts the innerHTML at the end of div 'contact-phones' in the form.
This is the function tied to the "Add" button Next to my phones:
function addPhone(){
var iteration = 0;
for (iteration=0;iteration<=100;iteration=iteration+1)
{
var targetDiv = 'Phone'+iteration+'div';
if(!$(targetDiv)){
break;
}
}
var myDiv=$('contactPhoneTemplate');
$('contact-phones').insert(new
Template(myDiv.innerHTML).evaluate({model: 'Phone',iteration:
iteration}));
}



On Feb 16, 11:53 am, Yaron  wrote:
> Dwayne, thanks for the detailed reply :)
> I'll try it later today when I have time and update here.
>
> Thank u guys!
>
> On Feb 15, 9:36 pm, Dwayne Hanekamp  wrote:
>
>
>
>
>
>
>
> > Hello Yaron,
>
> > For this u need to use the jquery plugin for dynamic forms 
> > (http://www.quackfuzed.com/demos/jQuery/dynamicField/).
> > The Librarian can click on a button and the new fields will appear.
> > For each field use a default name with [] at the end (which will make
> > it stack like a array) example: data[][book_id] after the fields have
> > been submitted, u will save them via a foreach-luss. something like:
>
> > foreach($data as $data){
> > $this->Book->create();
> > $this->Book->save($data);
>
> > }
>
> > Thats pretty much it! At least if i understand your question right!
>
> > On 15 feb, 18:56, Yaron  wrote:
>
> > > Hi,
> > > Suppose I have a book-borrowing application with a Customers table, a
> > > Books table and Borrowings table (customer_id, book_id and date
> > > fields).
> > > The borrowing view has three fields: customer, date and book (this
> > > field is a drop-down-box). Usually, a customer borrows more than a
> > > single book at once. The librarian does want to add one book at a
> > > time, but enter as many books as needed on the same view: when he
> > 

Re: Cakephp App::import() broken

2011-02-11 Thread LunarDraco
You might want to remove your closing ?> tag in the imported file(s).
It is not needed in a pure php file (those that DON't mix php and
html) which does not have any raw/html text to be displayed. And it
will ensure you have no problem with a trailing whitespace. Which I
think is probably the #1 problem for the error headers already sent.

Aslo run the whitespace task in the shell from DebugKit. I used to
always be surprised by what it found. And finally realized various
editors diffs, merge tools etc were the cause. Cant live without some
of those tools and I can't control the other developers working on the
project, so just remove the closing ?> in the files. PHP has never
required it. And it is a best practice on many php based app sites to
leave the closing ?> off.

You'll notice most(probably all) of the cakephp core for 1.3 like
core.php, bootstrap.php etc. has taken on this form or best practice
as well.

On Feb 10, 1:29 pm, Ryan Schmidt  wrote:
> On Feb 10, 2011, at 12:04, RLR wrote:
>
> > On Feb 10, 2011, at 11:48, RLR wrote:
>
> >> As soon as I put the following line in app_controller the Auth
> >> component and redirecting breaks with the following errors:
>
> >> App::import('Vendor', 'DateCalc', array('file' => 'date_calc.php'));
>
> >> Error in browser:
> >> Cannot modify header information - headers already sent by (output
> >> started at path-to-my-app/app/vendors/date_calc.php:1
>
> > As soon as I take the App:Import statement out everything works
>
> Then there is something about the file you're importing -- or one of the 
> files that file is importing -- that's causing this. If it's not something 
> deliberately being echo'd out, then perhaps whitespace before opening  tag or after closing ?> tag?

-- 
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: Has anyone connected cakePHP to SQL Azure?

2011-01-24 Thread LunarDraco
gobb0,

Microsoft SQL Azure can be connected to by php using the Microsoft SQL
Server Driver for PHP
So you should be able to connect to the db from CakePHP using the
dbo_mssql.php DataSource Driver.
http://book.cakephp.org/view/1075/DataSources

You see, Cakephp has supported Azure since before it was released. ;)
For connection String Info you should search for PHP and Azure.
But here is a good starting point.
http://blogs.msdn.com/b/brian_swan/archive/2010/02/12/getting-started-with-php-and-sql-azure.aspx


On Jan 21, 6:31 pm, cricket  wrote:
> On Fri, Jan 21, 2011 at 1:40 PM, gobb0  wrote:
> > Debating whether or not to use cakePHP or Ruby on Rails for a website
> > I intend to build. So far, I am finding more examples of RoR
> > connecting to SQL Azure. Given that Azure is relatively new, does this
> > mean that RoR is evolving faster than CakePHP? Appreciate it.
>
> It probably means that someone who uses RoR is interested enough in
> Azure (what's that?) to develop an interface to it. And that's
> probably about all anyone should read into it.
>
> Got any better questions?

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

2011-01-24 Thread LunarDraco
I do NOT see comments on the cakephp documentation to be valuable.

I think comments like php.net are great when your talking about how to
use a function. Most of the content of the cakephp book is how to use
the framework a little bit more extensive than a sequence of function
calls. This is where comments really don't help, the comments are
either not complete enough to really help anyone or they are
misleading and end up confusing more than they help.

Examples of use with decent explanations are extremely valuable, and
should be made part of the documentation, and I think the authors of
the book have been doing a great job at this in recent years. These
examples tend to take more effort to put together.

Submitted to git where the concepts can also be reviewed by the
architects of the framework and verified against best practice.
Best practice is another issue when you step past the function to the
framework. A lot of the comments go against best practice because it
takes to much effort to explain how to do it correctly in a comment.
This is why we see way too much code in the controller that should be
in the model.

I'm pretty sure for the most part we can all read an API for a
function. There are plenty of comments on usage of specific functions
and parameters in the google groups. A good number with links back to
the documentation. If you really want to see how to use a function
take a peek at the test case.

The documentation needs more real examples that focus on solving a
specific problem, or best practice on using a specific part of the
framework. This is where we can really add to the value of the
documentation.

Another problem with comments is when you go to convert or output your
documentation in different formats like PDF etc. You generally don't
get the comments which might show one or two good examples, or you get
all the comments regardless of how relevant they might be.

I vote for using a tool like sphinx for documentation. Using git and
community contributed commits to enhance the documentation. And I vote
for keeping comments and questions in the groups, IRC channels and
personal Blog space.

I really appreciate all the efforts the Core team has put into this
project. They have made the work I do more enjoyable, and less
tedious.
Keep up the great work!

-- 
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: Sharing data/values across different controllers

2011-01-17 Thread LunarDraco
Sharing data between controllers is generally not a good practice and
is a good indicator of heading down the wrong path.

Data should all be manipulated at the model level.
Explain a little more about the data your sharing between the two
controllers and why the data is coming from a controller instead of
the model.

On Jan 17, 9:27 pm, zer0_gravity  wrote:
> it worked thanks i realised i did not setup the session component
> variable
>
> thanks alot
>
> On Jan 17, 11:11 pm, zer0_gravity  wrote:
>
>
>
>
>
>
>
> > Could briefly explain the other ways because it is not working for me.
>
> > On Jan 17, 10:49 pm, tnbrooks  wrote:
>
> > > You could write them into session using something like:
> > > $this->Session->write('the_value', $value);
> > > then to access it in your other controller you just use:
> > > $this->Session->read('the_value');
>
> > > This is just one way..there are many others
>
> > > On Jan 18, 2:27 pm, zer0_gravity  wrote:
>
> > > > How Do I share a variable or data that exist in a particular
> > > > controller but do not exist in other controller(s)?
>
> > > > thanks

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

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


Re: How to implement CakePhp in an external site?

2011-01-13 Thread LunarDraco
>From your description you've given, I would say your placing your code
in the wrong place or in the wrong level of the MVC. (Model, View,
Controller) The order of this acronym also implies importance about
where you should be putting your code. Most of your code should be in
the Model, the business logic, calculation and manipulation of data.
The view is next in the list as we need to format all the data we just
finished manipulating. The Controller should have the least amount of
code as its main purpose is to tie the user requested events to the
business logic and control which model functions should be called, and
to pass the already calculated data from the models to the view.

Think of them in this manner Models return Data, Controllers return
Views.

Often new developers to the MVC development structure end up building
apps where most of the code lives in the controllers and the models
are bare and relying on the core functions inherited from the base
model. They quickly find themselves in your position where you want to
use some code from a function in Controller2 to manipulate some data
from within Controller1 and find that it is very difficult to call on
another controller.

Models on the other hand are available to use from any other model in
the structure. Code put in a model can be called by both other models
as well as by the controllers.

Do your best to make your Models Fat with your data manipulation and
your Controllers Thin and you'll find the MVC framework is a great
design.

So your simple case might look more like this:
class Model2
{
 belongsto Model1
 function getComplexData(){
$this->find(something);
$this->Model1->customfunction();
//combine and play with data returned from model1 and model2
   }
}

 class Controller 1
 {
    function func1(){  //No data manipulation in the controller.
   $data = $this->Model2->getComplexData();
   $this->set(data); //pass data to view for display
   }
 }


On Jan 13, 6:54 am, Axel  wrote:
> Hello,
>
> I'm starting to use CakePHP and it looks very nice. However, its main
> prupose seems to be management of relation with database and
> subsidiaries of these actions (showing results, etc...)
>
> In my case, I would like to create a site where I will have to do
> calculations with the data, sorting, etc... and these are using many
> method in different controllers, like :
>
> Model 2 belongsto Model 1
>
> class Controller 1
> {
>    function func1(
>
>         //recover data from model 1
>        // recover data from model 2 via loadModel
>
>        //Use function func2 from Controller 2
>        // combine and play with data returned from func2 and from
> Model1
> (...)
>    )
>
> }
>
> It's the simplest case and it can vary a lot. The problem is that I
> need requestAction to load func2 (is it ?). So, as it is very slow, I
> was thinking of using my own external structure (which is already
> built :D) and inside of this, doing some includes that recover the
> data of model1 and model 2, play in my own stuff, pass it inside of
> func2, play it ...etc.. etc...
> 1) it is easier in order to play with the values
> 2) no needs of request actions..etc
>
> I don't know if how to do that, and if it's a good way to use it.
>
> What do you think about it? Where can I put my fileS?
>
> Thank you
>
> PS : is this a help forum ?  Hope i'm not in the wrong place.

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

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


Re: Multiple apps / one login

2010-10-26 Thread LunarDraco
I solved this problem by having one app handle all of my logins and
then redirect after authentication to one or more of the other sites.
In the redirect I pass the users temporary token to the second site.
In all the sites during the app.beforefilter I check for this passed
params decode it and read from the model the user that was passed in
and then I set auth true and skip that sites login.

This technique has worked well across multiple servers and even across
technologies meaning going from CakePHP on a linux box to a .Net
server on Windows and later back to the linux box.

>From the users point of view they have no idea how many times they
switch from one server to another unless they are really watching the
url.


On Oct 24, 2:56 am, hapoo  wrote:
> I've experimented and successfully implemented Auth and Acl on one
> app. However I want to design a site with multiple independent apps
> which all share one login system/DB. For example the main site
> (example.com) will be one app. The blogs (example.com/blog) will be
> another app, and the recipe page (example.com/recipe) will be yet
> another app. But I want them all to use a single login and act like
> one coherent site. Is there any way to do this? Thanks

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

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


Re: Starting a programming blog, should I use CakePHP or wordpress?

2010-09-15 Thread LunarDraco
True that there is additional maintenance, and documentation required.
Which I believe is worth it.
However I would argue that I and many developers in the past have
tried to force a single platform/language/db etc. The reality is we
(and our clients) cannot afford to rewrite everything using our new
favorite tool of the year. Especially when there are other tools that
already do a better job at it than what we might put together giving
the time, cost, minimal requirements etc. Some clients may want a all
in one and have the money to pay for and be willing to wait long
enough for the code to be completed. I just haven't found any of those
clients yet.

I've picked what at the time seemed to be the best software in its
market space for a specific subsystem. Learn how to use it well.
On occasion if the tool is lacking a requested feature I would re-
evaluate the available options and switch my preferred tool for that
subsystem.

Having an integrated layer also means we can swap out that subsystem
if something better suited comes along. And this I believe is the
proper way to keep a large system migrating to newer tools.

I agree this has been a good discussion and I don't think there is a
right or wrong way to answer and solve the problem, as a matter of
fact I think each situation needs to be evaluated and analyzed.

I do the same thing when I'm setting up a new physical network, I use
a certain brand and class of hardware on all my installs. I know the
interfaces well and I am familiar with the hardwares faults.

At some point we as a development community started looking back at
what we've tried and what works best. Often we've found what we
thought was the best way to do something was completely wrong. The
Gang of Four did this best. A process we should all continue to do is
a self evaluation of our efforts and their results.

Have a great day Coding today!

On Sep 14, 11:58 am, "j.blotus"  wrote:
> Lunar, your approach sounds good in the sense that it will get you up
> and running quickly (other than having to learn how to use some new
> piece of code and dealing with those bugs), but from all the patching
> together it sounds like a maintenance nightmare! Thanks for the
> insight though this tread as been quite interesting and helpful.
>
> On Sep 14, 1:02 pm, LunarDraco  wrote:
>
> > If you want to really do anything with cake and a blog system, I would
> > say your best effort would be in learning how to integrate and use an
> > existing blogs API
>
> > For my clients I'm usually being asked to solve a problem. More often
> > than not that problem is an integration problem between already
> > implemented and heavily used systems. I need to bring a business
> > concept together which often includes payment options, blogging,
> > email, graphs, maps, OpenID, etc a whole slue of subsystems which
> > already exists. You'll have a more complete toolbox if you learn how
> > to properly use and integrate with these other systems via their
> > published API's. This activity of learning to use an API from within
> > cakephp will cover two aspects being discussed. It will give you the
> > opportunity to learn and practice writing cakephp apps, plugins,
> > behaviors, components, and helpers. And at the same time give your
> > cakephp app access to some really complete subsystems like WordPress,
> > Google Maps, Google Analytics, Annotated Time line, PayPal,
> > QuickBooks, etc.
>
> > Anytime you can use the resource of hundreds of other developers to
> > help you build your system I'd take full advantage of that.
> > I use cakephp, sql, php, crons etc to glue all the other subsystems
> > together into one cohesive system of applications for the client. I
> > write what I can't find or when the tools I do find do not provide a
> > clean way to integrate or are just to difficult to modify to the
> > clients needs. I have web apps that are a mix of servers Linux,
> > Windows, and seamlessly integrate between apache and IIS with mixed
> > dbs of MSSql and MySql. From the users point of view they are in one
> > app.
>
> > I really believe our industry has leaped past the one off apps. We
> > don't build apps anymore, we integrate, build and organize systems. If
> > you do build a one off app, I'll guarantee you the first request your
> > client will ask is can we integrate this with our  system/app?
> > I love cakephp because its structure allows me to integrate, build and
> > use these other systems. A few of my cake apps are never viewed by
> > human eyes, they run as cron/shell apps to move data between systems
> > that don't know how to work together. The Model Controller layers
> > 

Re: Starting a programming blog, should I use CakePHP or wordpress?

2010-09-14 Thread LunarDraco
If you want to really do anything with cake and a blog system, I would
say your best effort would be in learning how to integrate and use an
existing blogs API

For my clients I'm usually being asked to solve a problem. More often
than not that problem is an integration problem between already
implemented and heavily used systems. I need to bring a business
concept together which often includes payment options, blogging,
email, graphs, maps, OpenID, etc a whole slue of subsystems which
already exists. You'll have a more complete toolbox if you learn how
to properly use and integrate with these other systems via their
published API's. This activity of learning to use an API from within
cakephp will cover two aspects being discussed. It will give you the
opportunity to learn and practice writing cakephp apps, plugins,
behaviors, components, and helpers. And at the same time give your
cakephp app access to some really complete subsystems like WordPress,
Google Maps, Google Analytics, Annotated Time line, PayPal,
QuickBooks, etc.

Anytime you can use the resource of hundreds of other developers to
help you build your system I'd take full advantage of that.
I use cakephp, sql, php, crons etc to glue all the other subsystems
together into one cohesive system of applications for the client. I
write what I can't find or when the tools I do find do not provide a
clean way to integrate or are just to difficult to modify to the
clients needs. I have web apps that are a mix of servers Linux,
Windows, and seamlessly integrate between apache and IIS with mixed
dbs of MSSql and MySql. From the users point of view they are in one
app.

I really believe our industry has leaped past the one off apps. We
don't build apps anymore, we integrate, build and organize systems. If
you do build a one off app, I'll guarantee you the first request your
client will ask is can we integrate this with our  system/app?
I love cakephp because its structure allows me to integrate, build and
use these other systems. A few of my cake apps are never viewed by
human eyes, they run as cron/shell apps to move data between systems
that don't know how to work together. The Model Controller layers
accompanied with a few components like task queue and some crons makes
cake a great way to add background functionality to legacy systems.
I'm still a one man team, but that is only possible because I use
systems that are actively supported by many hundreds of developers and
community members.

You can't go wrong in learning how to integrate and use these other
subsystems. By doing so you add a lot of functionality to your toolbox
with very little effort. At least a lot less effort than rolling your
own.


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

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


Re: Mdy date validation fails for Sep instead of Sept

2010-09-14 Thread LunarDraco
Date format is a very interesting problem. Mostly though only in the
US.
The order and format of a date can take on many forms. For some reason
in the US the common public form is Month Day, Year as in Sep 1, 2010
abreviated 9/1/2010 where if you abbreviate with hyphens instead of
'/' as in 9-1-2010 this represents 9 Jan 2010.

All most everywhere else on the planet the format is Day Month Year as
in  1 Sep 2010 or 1-9-2010
Programatically in SQL we use year-month-day hour:min:second.micro.
2010-09-01 12:00:00.123
ISO 8601 2004-02-12T15:19:21+00:00
As validation is for verifying data input we need to consider the
mindset of the community that will be using our software and provide
the proper conversions from that input to the format we need for our
Database etc.
Explore php parse_date() and see what it makes of all the different
formats.

On top of all of this info it seems that September is the only month
that has two acceptable short or abbreviations (Sep, Sept) all the
other months only ever use 3 chars.

If you adjust the regex to the following both short forms will
validate. Sep as well as Sept
This looks to be something that might be worth entering a defect for.
I'm not sure if the core team was trying to match the short form of a
given spec or some other standard. But most of my validations are for
the benefit of the user not some specified standard. Further more most
of my users are lazy and that extra 't' is just to much for some of
them to type ;)
If the short form Sep 1, 2010 is not truly valid say for the database
date format etc. Then you would want/need to add some beforeSave code
to clean up the format. I haven't look real deep into the cakephp code
in how the Date data is converted back and forth between the UI
display and the Database, but if its using the parse_date() function
both formats work correctly.

$regex['Mdy'] = '/^(?:(((Jan(uary)?|Ma(r(ch)?|y)|Jul(y)?|Aug(ust)?|
Oct(ober)?|Dec(ember)?)\\ 31)|((Jan(uary)?|Ma(r(ch)?|y)|Apr(il)?|
Ju((ly?)|(ne?))|Aug(ust)?|Oct(ober)?|Sep(tember)?|(Sept|Nov|Dec)
(ember)?)\\
(0?[1-9]|([12]\\d)|30))|(Feb(ruary)?\\ (0?[1-9]|1\\d|2[0-8]|(29(?=,?\\
((1[6-9]|[2-9]\\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|
[3579][26])00)))\\,?\\ ((1[6-9]|[2-9]\\d)\\d{2}))$/';

On Sep 12, 2:19 pm, Imaginextra  wrote:
> I came across the same problem ... The way I found to fix it was to
> change line 403 in cake>libs>model>validation.php (Cakephp 1.3.4)
> from
>
> $regex['Mdy'] = '/^(?:(((Jan(uary)?|Ma(r(ch)?|y)|Jul(y)?|Aug(ust)?|
> Oct(ober)?|Dec(ember)?)\\ 31)|((Jan(uary)?|Ma(r(ch)?|y)|Apr(il)?|
> Ju((ly?)|(ne?))|Aug(ust)?|Oct(ober)?|(Sept|Nov|Dec)(ember)?)\\ (0?
> [1-9]|([12]\\d)|30))|(Feb(ruary)?\\ (0?[1-9]|1\\d|2[0-8]|(29(?=,?\\
> ((1[6-9]|[2-9]\\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|
> [3579][26])00)))\\,?\\ ((1[6-9]|[2-9]\\d)\\d{2}))$/';
>
> to
>
> $regex['Mdy'] = '/^(?:(((Jan(uary)?|Ma(r(ch)?|y)|Jul(y)?|Aug(ust)?|
> Oct(ober)?|Dec(ember)?)\\ 31)|((Jan(uary)?|Ma(r(ch)?|y)|Apr(il)?|
> Ju((ly?)|(ne?))|Aug(ust)?|Oct(ober)?|Sep(tember)?|(Nov|Dec)(ember)?)\\
> (0?[1-9]|([12]\\d)|30))|(Feb(ruary)?\\ (0?[1-9]|1\\d|2[0-8]|(29(?=,?\\
> ((1[6-9]|[2-9]\\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|
> [3579][26])00)))\\,?\\ ((1[6-9]|[2-9]\\d)\\d{2}))$/';
>
> not recommended to mess with the core but it works.
>
> On Aug 4, 5:03 pm, Brenda  wrote:
>
> > I have event_date in my model, with this validation rule:
>
> >         'event_date' => array(
> >             'rule' => array(
> >                 'date', array('Mdy')
> >             ),
> >             'required' => true,
> >             'allowEmpty' => false,
> >             'message' => 'Please enter a valid date.'
> >         )
>
> > Entering Sept 1, 2010 validates, but Sep 1, 2010 does not. Is that
> > correct behavior?
>
> > Thank you.

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

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


Re: sending multiple email

2010-08-05 Thread LunarDraco
This is a working solution, however you will eventually run into
problems with this solution. The first may be browser timeout.

Many ISP's have limits on how many emails per hour, and how much data
per hour can be sent out before you are black listed. Whats missing
from your solution is called throttling. So you don't flood the
server.

I would suggest you use the queue plugin http://github.com/MSeven/cakephp_queue
to first background this work so your browser isn't waiting for it to
finish.
Once you have the work running in the background now you can take the
appropriate amount of time to process your loop and stager the emails
being sent so the email server doesn't flag you as flooding.

On Aug 4, 1:12 am, fadhli  wrote:
> i found the answer. this is my code to send mail to all client.
>
> function sendall() {
>                 $this->Client->recursive = 0;
>         $this->set('clients', $this->Client->find('all'));
>                 foreach ($clients as $client) {
>                         $this->Email->reset();
>                         $this->Email->to = $client['Client']['email'];
>                         $this->Email->subject = 'update request';
>                         $this->Email->replyTo = 'no-re...@x.com';
>                         $this->Email->from = 'xx ';
>                         $this->Email->template = 'simple_message';
>                         $this->Email->sendAs = 'html';
>                         $this->set('client', $client);
>                         $this->Email->send();
>                 }
>                 if ( $this->Email->send() ) {
>                         $this->Session->setFlash('email been sent');
>                 } else {
>                         $this->Session->setFlash('email not sent');
>                 }
>                 $this->redirect(array('action'=>'index'));
>         }
>
> On Wed, Aug 4, 2010 at 12:59 AM, fadhli  wrote:
> > hi everyone.
>
> > i want to send email to all my client, the email contains client data, so
> > the email different between the client. how to send email to all client at
> > ones? i have read
> >http://book.cakephp.org/view/1285/Sending-Multiple-Emails-in-a-loopbut i
> > don't know how to repeat sending email in my controller. can you give me an
> > example? thanks.
>
> > This is my code for sending an email to one client
>
> >  function _sendmail($id) {
>
> >>                 $client = $this->Client->read(null, $id);
>
> >>                 $this->Email->to = $client['Client']['email'];
>
> >>                 $this->Email->subject = 'update request';
>
> >>                 $this->Email->replyTo = 'no-re...@x.com';
>
> >>                 $this->Email->from = 'X ';
>
> >>                 $this->Email->template = 'simple_message';
>
> >>                 $this->Email->sendAs = 'html';
>
> >>                 $this->set('client', $client);
>
> >>                 $this->Email->send();
>
> >>         }
>
> >>>         function send($id) {
>
> >>                 if (!$id) {
>
> >>  $this->Session->setFlash(sprintf(__('Invalid %s', true), 'client'));
>
> >>  $this->redirect(array('action' => 'index'));
>
> >>  }
>
> >>                 $this->_sendmail($this->Client->id);
>
> >>                 $this->Session->setFlash(sprintf(__('The %s email update
> >>> request has been send', true), 'client'));
>
> >>                 $this->redirect(array('action' => 'index'));
>
> >>         }

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

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


Re: Sending StatusMails by CronJob - what is the right approach?

2010-08-05 Thread LunarDraco
This is exactly how my app works.
I can as an auth admin via the browser hit my controller action to
send out notifications.
The same Controller action can be called from the shell in interactive
mode in which it outputs info about what emails were sent.
The same Controller action can be called from the crontab where no
information is output this is controlled by a parameter passed to the
shell command.

My Controller function:
function notify(){
$this->layout = 'default';
$conditions = array('Profile.notify' => 1);
$recievers = $this->Profile->find('all', array('conditions' =>
$conditions));
if (!defined('FULL_BASE_URL')) {
define('FULL_BASE_URL',
Configure::read('Sandbox.site.url'));
}
foreach($recievers as $reciever){
if($reciever['Profile']['notified'] == null){
$reciever['Profile']['notified'] = date('Y-m-d H:i:s',
Time() - (1440*60*14));
}
$curTime = date('Y-m-d H:i:s', Time());
$vardump = $this->Project->findnew($reciever['Profile']
['notified']);
//$this->set('notifiee', $reciever);
//$this->set('email', $vardump);
if(!empty($vardump)){
$this->set('notifiee',$reciever);
$this->set('email', $vardump);
$this->Email->_debug = false;
$this->Email->reset();
$this->Email->charset = 'iso-8859-15';
$this->Email->to = $reciever['Profile']['email'];
$this->Email->subject = 'New Projects and
Attachments';
$this->Email->replyTo =
Configure::read('Sandbox.site.email');
$this->Email->from =
Configure::read('Sandbox.site.name').'<'.Configure::read('Sandbox.site.email').'>';
$this->Email->template = 'projectemail';
$this->Email->sendAs = 'html'; // because we 
like to send pretty
mail
$this->Email->delivery = 'smtp';
if($this->Email->send()){
$this->Profile->id = $reciever['Profile']['id'];
$this->Profile->saveField('notified', $curTime);
}else{$this->log('Notify email could not be sent');}
}else{
//update the notified date.
$this->Profile->id = $reciever['Profile']['id'];
$this->Profile->saveField('notified', $curTime);
}
}
exit;
$this->layout = 'default';
$this->pageTitle = 'Sample Test Email';
}

Here is my vendors\shells\notify.php:
It simply loads and sets up the Controller and EmailComponent
And then calls the controller function listed above.

ProfileController =& new ProfilesController();
$this->ProfileController->uses = array('Profile','User');
$this->ProfileController->Profile =& new Profile();
$this->ProfileController->Project =& new Project();
$this->ProfileController->Email =& new EmailComponent();
$this->ProfileController->Email->initialize($this-
>ProfileController);
$this->_loadModels();
}


function main() {
$this->send();
}

function startup() {
$this->out('Cake notify sends emails of new Projects and 
Attachments
'.date('Y-m-d',time()));
$this->hr();
}

function help() {
$this->out('CakePHP Notify:');
$this->hr();
$this->out('The Notify script sends emails to all profiles ');
$this->out('that are set to be notified.');
$this->out('The email contains all Projects and Attachments');
$this->out('which have been updated since the last time a
notification');
$this->out('Was sent.');
$this->out('This shell is intended to be called from a cron 
job.');
$this->hr();
$this->out("Usage: cake notify send ...");
$this->hr();
$this->out('Commands:');
$this->out("\n\tnotify help\n\t\tshows this help message.");
$this->out("\n\tnotify send\n\t\t sends emails.");
$this->out("\n\tinteractive is passed as a 1 or 0. When set to 1
will echo status info.");
$this->out("");
print_r($this->interactive);
}

function send(){
if (isset($this->args[0])){
$this->interactive = $this->args[0];
}
$this->ProfileController->notify();
}

}
?>

On Aug 3, 3:17 pm, DigitalDude  wrote:
> Hey,
>
> that makes perfectly sense and I think I would prefer this one, too.
> There are two things I'm worried about:
>
> 1) I will need some sort of authentication to prevent calling those
> actions f

Re: model associated to the same model

2010-07-26 Thread LunarDraco
http://book.cakephp.org/view/851/Multiple-relations-to-the-same-model


On Jul 26, 1:03 am, danix  wrote:
> ok! I will try it.
>
> Thanks!
>
> On 26 jul, 00:41, cricket  wrote:
>
> > On Sun, Jul 25, 2010 at 11:34 AM, danix  wrote:
> > > Hello,
>
> > > I've two models: User and Group. Users can be "parent" or "son".
> > > A parent can have many sons. And a son can belong to one parent.
>
> > > Can I use "hasAndBelongsToMany"??
> > > Or I need to use hasMany and belongsTo in the same model?
>
> > > Maybe I need to create the model "Family" with hasMany relationship
> > > with Users. Only one "parent" and many "sons".
>
> > Sorry about that.
>
> > Something like this should work:
>
> > public $belongsTo = array(
> >         'Parent' => array(
> >                 'className' => 'User',
> >                 'foreignKey' => 'parent_id'
> >         )
> > );
> > public $hasMany = array(
> >         'Child' => array(
> >                 'className' => 'User',
> >                 'foreignKey' => 'parent_id'
> >         )
> > );
>
> > The 'Parent' and 'Child' are aliases that Cake will use to set up the
> > data array.

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

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


Re: Display images outside webroot folder

2010-07-26 Thread LunarDraco
When the images are uploaded do you save any information into your db
that associates to the filename on disk?

If you do you could use that model's controller and an action like
getimage and then use the media helper to return the file.

as in myapp/users/getimage/somename

This can further be enhance with named parameters to match to a
specific user
myapp/users/getimage/uid:20/fname:somename

Media View allows you to return binary data from a controller action
with a specific header that identifies its type. The controller and
model have access to the folders outside the browsers view and can
read the file and return it as a specific image.
http://book.cakephp.org/view/489/Media-Views

I use this technique to track when emails have been read. One of the
space.gif images in my emails has unique named parameter which ties it
directly to a specific sent email. So when it is read the controller
action updates the sent email as read and the gif that is returned is
a file in my templates folder.

On Jul 26, 5:15 pm, cricket  wrote:
> On Mon, Jul 26, 2010 at 7:56 AM, rez...@gmail.com  wrote:
> > thanx
>
> > the project files structure
> > /
> > /webroot
> > /userFiles
> > /controllers
> > /models
> > /vendors
> > ..
> > ..
> > etc
>
> > is userFiles folder outside document root ?
>
> Yes, the "root" of your site is the webroot dir (hence the name).
> Anything in there can be accessed directly (like, /css/whatever.css,
> /img/whatever.jpg, or /foo.html).
>
> > whats can I do to make a separated image folder for users ?
>
> There are three (that I know of) ways to go about this using existing
> code. MediaView [1], Nick Baker's FileUpload plugin [2], or David
> Persson's Media plugin [2]. I haven't used the latter, although I have
> looked at the code. It seems very complete but, as I said, I haven't
> used it. The FileUpload plugin works great, although I've never used
> the helper part of it.  I don't know if it's a very good solution if
> you'll be serving lots of these files. If so, you should consider
> caching. Ditto for MediaView.
>
> [1]http://book.cakephp.org/view/489/Media-Views
> [2]http://github.com/webtechnick/CakePHP-FileUpload-Pluginhttp://bakery.cakephp.org/articles/view/file-upload-component-w-autom...
> [3]http://wiki.github.com/davidpersson/media/

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

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


Re: Inflections + Naming Conventions Generator?

2010-07-22 Thread LunarDraco
Not sure the rules on pasting code here but my weekend is starting for
me and wanted to post what I had. A few function are incomplete but I
think its a good start.
Try something like
cake inflect core events_contacts
Watch the detail about the warnings and suggestions.
enjoy!

file vendors/shells/inflect.php

hr('=');
$this->out('Cake Inflect shows the various Inflections used for 
the
given input.');
$this->hr();
if(empty($this->args[0])){
$this->help();
exit();
}
}
//TODO add named parameters for controller:Cakes table:cakes
model:Cake action:getCake
//to see how things should be mapped when not following the
standards.

function help() {
$this->hr('+');
$this->out('CakePHP Inflect:');
$this->hr();
$this->out('The Inflect console script shows all the various
inflections given an input based');
$this->out('on the defined cake standards. The input can be in
various formats: singular, plural,');
$this->out('lower_underscored, CamelCase functionCase etc.');
$this->hr();
$this->out("Usage: cake inflect [InputType] word 
[TypesForCustom]");
$this->hr();
$this->out('Show a summary of all possible inflections for the 
given
word as InputType.');
$this->out("InputType when not given defaults to 'core'");
$this->out('InputType can be one of:');
$this->out('   all - includes core, component, behavior, 
helper');
$this->out('   core - (default) includes table, model, 
controller,
action');
$this->out('   custom - allows list of inputs after word like 
model
controller');
$this->out('   table');
$this->out('   model');
$this->out('   controller');
$this->out('   action');
$this->out('   component');
$this->out('   behavior');
$this->out('   helper');
$this->out('   cakeclass');
$this->out('word - the word to analyze try people, person,
ContactsEvents, EventsContacts, etc.');
$this->hr();
$this->out('ex: cake inflect core people');
$this->hr();
}

function main()
{
$this->core();
}

function all(){
$this->core();
$this->behavior();
$this->component();
$this->helper();
$this->cakeclass();
}

function core(){
$this->table();
$this->model();
$this->controller();
$this->action();
}

function custom(){
if(!empty($this->args[1])){
$argcount = count($this->args)-1;
for($i = 1; $i <= $argcount; $i++)
{
$function = $this->args[$i];
$this->$function();
}
} else {
$this->core();
}
}

function table($input = null)
{
if(empty($input)){
$input = $this->args[0];
}
$this->hr('=');
$this->out('=== '.$input.' as a Table');
$this->hr('=');
$singular = Inflector::singularize($input);
$plural = Inflector::pluralize($input);
if($singular == $input){
$this->out($input.' is Singular note table name is 
pluralized.');
$this->hr();
}
$tablename = Inflector::tableize(Inflector::camelize($input));
$this->out('Table Name:'.$tablename);
$this->out('FK Pattern:
'.Inflector::singularize($tablename).'_id');
$this->hr();
$this->out('Model Class Name:
'.Inflector::classify($singular));
$this->out('Controller Class Name:
'.Inflector::camelize($plural).'Controller');
$words =
explode('_',Inflector::tableize(Inflector::camelize($input)));
$pluralCount = 0;
$tables = array();
foreach($words as $table){

if(empty($tables[$pluralCount])){
$tables[$pluralCount] = $table;
} else {
$tables[$pluralCount] = 
$tables[$pluralCount].'_'.$table;
}
//TODO Add code to convert form of each word to and 
from single and
plural for Condition of FreindsPeople
if(Inflec

Re: Inflections + Naming Conventions Generator?

2010-07-22 Thread LunarDraco
I've got a console task I've started that does some of this, I
originally built it to figure out what cake was doing with a specific
multi word table I had.
But this is a great idea I'll work on my implementation a bit more and
then post it to github with a follow up post to this thread.
I think a console task over a web service will be cleaner because I
will want to use my specific apps inflections.php file which has some
additional rules like geese -> goose etc. as well as to be able to see
the real full paths for my app in the right format for linux or
windows. Really to be relative to my apps specific environment.

some example uses might be:
cake inflect table people
cake inflect class person
cake inflect controller
cake inflect action
cake inflect url controller/action/param

cake inflect table people
which would output all of the inflection info you should be using:
Table: people
fk: person_id
ModelClass Person
ModelPath /home/myfolder/myapp/models/person.php
ControllerClass PeopleController
ControllerPath /home/myfolder/myapp/controllers/people_controller.php
etc.

The ones I always get stuck on are the double words like:
contact_events or contacts_events or contacts_event

I've verified that it is possible to identify if a word is singular or
plural and then maybe from that build out the rest If i can accomplish
this then the command would be cake inflect people
So cake inflect people would identify it as plural and build out all
the output based on that.
cake inflect person should then output the exact same info as cake
inflect people with the model always equal to Person, table = people
etc.

We use inflection for models(Class, File, Table), controllers(Class,
File, actionNames), views(Path, File) Any others that might be worth
adding to this util let me know.

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

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


Re: $validate Does not work as expected!

2010-07-22 Thread LunarDraco
You haven't shown us the structure of $this->data for all we know the
mdate field does exist and is an array of datetime format which means
its not empty even though the values of each name value pair in the
array maybe Empty.

Also what does your form create code look like. Do you have a hidden
input field for the mdate. Are you creating the form with the
formHelper.

Just curious but why did you add this action to pages instead of a
contact controller or element?

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

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


Re: translate behavior: no join for default language?

2010-07-21 Thread LunarDraco
I would make the data schema design the same or consistent regardless
of the language.
Anytime you introduce a special case to your design you really
complicate the supporting code for reading, writing and displaying the
data. You'll end up doing all kinds of conditional checking for that
one special case.

So the direct answer to your question is yes it can be done, but the
how to do it is going to unnecessarily complicate the code. And from a
users stand point they won't see or appreciate the more complex design
because from their point of view both designs would be viewed the
same.

If you need a default language make this a site setting not a hard
design structure in the schema.

On Jul 20, 3:58 am, M  wrote:
> for example, i have posts table and i18n table. posts table already
> have data in english so i created data of the other language in i18n.
>
> i was wondering if there's a way to retrieve data from posts table
> when language is english. or do i have to create english data in i18n
> table?

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

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


Re: Cannot send the email to more than one recipient.

2010-07-15 Thread LunarDraco
I ran into the same problem a long while ago.
And your right the to is a string but the component doesn't do
anything with the $to var except pass it off to the php mail function.

The way the php mail function processes the mail depends on how it is
configured. If you search for "php mail sending to more than one
email" you'll see almost all of the example solutions use a loop to
send the same email to multiple individual 'to' emails. The php mail
documentation indicates that you can send to multiple by separating
with a ',' but I've yet to see anywhere explain exactly how to
configure your mail subsystem to support it. I'm currently using
postfix on my local dev and local server. Not sure exactly what my
deployed host is using.

The problem has nothing to do with the email component but rather with
the email subsystem on the machine/host your running on. The php mail
documentation also gives plenty of warnings about differences between
windows and linux and weather or not you have a MTA running etc.

I think a single to recipient is a better design pattern as it keeps
the email address more private. It also allows better design for
sending to large groups as I believe there is a limit to the number of
email addresses. If I need to send to a group then I send to myself or
a blackhole email address and cc all the others. The only reason I
would do that is if I needed to allow or expected the recipients to
carry on a thread via reply to all.

I never did figure out how to setup my local mail system to handle
multiple to recipients, and I figured I would run into similar
problems with different host so I looked for a more manageable
solution.

I moved to the swiftmailer component to make better use of the SMTP
and ssl connections thus by passing most of whatever mail subsystem
was installed on the host and connecting directly to a known dedicated
smtp server. However I still send the email to one recipient.

You'll need to either send multiple copies of the same email to each
person via a loop
Or add the additional emails to the CC or BCC array.


On Jul 14, 9:17 pm, googong  wrote:
> Yes other options are fine
> -one "to" recipient,
> -one and many "cc" recipient.
> -one and many "bcc" recipient.
>
> I wonder why "to" option need to be string because cc and bcc are
> array and it works fine.
>
> On Jul 15, 6:37 am, nurvzy  wrote:
>
> > Can you get it to work with just one recipient? Because my first
> > question is if you (or your host) has setup sendmail properly.  You
> > can always use a SMTP server to send your mail which is usually
> > recommended for bulk email anyway.
>
> > Nick
>
> > On Jul 13, 9:27 pm, googong  wrote:
>
> > > Hi all,
> > > I follow the 
> > > documenthttp://book.cakephp.org/view/1284/Class-Attributes-and-Variables
> > > to send mail.
>
> > > "Address the message is going to (string). Separate the addresses with
> > > a comma if you want to send the email to more than one recipient."
>
> > > I tried to send many "to" email with separate comma like
> > > "addre...@domain.com, addre...@domain.com" but nothing happen when run
> > > the script.
>
> > > Any suggestion?
> > > Thank you very much
> > > googong.

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

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


Re: CSV Helper not rendering on web host, but works on localhost

2010-07-12 Thread LunarDraco
I'd make sure your layout you are using for the csv is being copied
out to your web host. If it is missing cake is going to use its
default layout which is going to have the headers etc set for html/
text.


On Jul 9, 12:23 pm, CapeTownGuy  wrote:
> Hi, I'm using the CSV helper and it works fine on my localhost,
> however as soon as I upload to a web host, it stops working.
>
> The only clue I could glean is that the content type is different on
> the web host, however I have no idea why it changes from the correct
> mime type on localhost to text/html on the web host.

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

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


Re: Need CSV import: best practices?

2010-07-02 Thread LunarDraco
I placed my csv import logic in my model and will probably move
portions of it to a behavior as soon as I need to import more than the
one type of model data.
The reason for this is I needed to handle large record count imports
where there was a substantial amount of related data in the imported
csv. This processing of the imported data can be very time consuming
and I didn't want the user to sit and wait for the import to complete
as they don't need to deal with it all right away. And at times it
would exceed my timeouts if I did wait for it.
So in my controller I accept and save the imported csv file. The
controller then calls the model to import the first X (50) number of
records from the file and returns control and displays these to the
user. An entry is added to my background queue to finish the import
starting at record 51. The background queue takes place from a shell
task calling the same code in the model.
Having the import logic and decision logic in the model is easier to
access from both the Controller and the Shell Task so I don't have
duplication. It also provides a clean path for Unit Testing.
I'm a big proponent of Fat Models for these same reasons. It
simplifies testing, its accessible from multiple controllers and it
simplifies use in a shell task.
I realize that it is possible to create an instance of a Controller
from a shell task and that its possible to test code in a Controller.
However it is much simpler to use and test model code.
A simple litmus test question is how can I test this code, and can I
use it from other controllers and the shell if I needed to. That will
tell you where your code should be placed.

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

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


Re: Hierarchy problem

2010-06-29 Thread LunarDraco
You could build a join set which will force the items to the same
array level.
http://book.cakephp.org/view/872/Joining-tables

On Jun 28, 9:13 am, Hugo M  wrote:
> Well best the solution I found will be migrating from MySQL to Postgres,
> because Postgres can have both foreign key and full text indexes in the same
> table.
>
> Regardss
>
> 2010/6/25 Hugo Massaroli 
>
> > Well, maybe not... the thing is that Fulltext is a table MyISAM and Item is
> > InnoDB. That's because I only can have fulltext indexes (that helps for
> > searchers) in MyISAM tables but in MyISAM engine I do not have FOREIGN KEYS
> > :S.
>
> > But... in Item table I really don't have important foreign keys so maybe
> > the solution will be mix both tables, so it's a good idea, and put all data
> > in a unique MyISAM table. The problem is that I don't know if I can have a
> > foreing key in a InnoDB table referencing a MyISAM table. Yeap, that's the
> > real problem :S
>
> > 2010/6/25 cricket 
>
> > On Thu, Jun 24, 2010 at 10:13 PM, Hugo M  wrote:
> >> > Hi there! I have this structure:
>
> >> > Recommend hasOne Item
> >> > Item hasOne ItemFulltext
>
> >> > (ItemFulltext are fields from the item)
>
> >> > When I do a Recommend->find() I get:
>
> >> > Array
> >> > (
> >> >    [0] => Array
> >> >        (
> >> >            [Recommend] => Array(...)
>
> >> >            [Item] => Array (
> >> >                 [ItemFulltext] => Array(...)
> >> >             ...)
> >> >        )
> >> > )
>
> >> > I want one of two things:
>
> >> > 1) Put ItemFulltext in the same level as Item
> >> > ...
> >> > or mixing two tables in one model... (better)
>
> >> Is it really necessary to have a separate ItemFullText model? Why not
> >> put that data in items table?
>
> >> Check out the new CakePHP Questions sitehttp://cakeqs.organd help
> >> others with their CakePHP related questions.
>
> >> You received this message because you are subscribed to the Google Groups
> >> "CakePHP" group.
> >> To post to this group, send email to cake-php@googlegroups.com
> >> To unsubscribe from this group, send email to
> >> cake-php+unsubscr...@googlegroups.comFor
> >>  more options, visit this group at
> >>http://groups.google.com/group/cake-php?hl=en

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

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


Re: How i decode md 5 in cake php

2010-06-28 Thread LunarDraco
MD5 hash is meant to be a one way process. The difference between a
hash and an encryption is exactly that a hash is never really meant to
be decoded where an encryption algorithm is a two way encode<->decode
process.
So you really shouldn't be trying to decode a hashed MD5.
Perhaps your using the wrong type of algorithm to solve your problem.

You'll get better answers when you provide a little more detail about
what you are trying to accomplish.

On Jun 25, 12:26 am, Dilip Godhani  wrote:
> Hello frd
> Can any one tell me how i decode md5 in cakephp
>
> Thanks
>
> Dilip Godhani
> Software Developer,
> Entourage Solutions
> e-mail: di...@entouragesolutions.com
>           dilip.godh...@gmail.com
> Web.:www.entouragesolutions.com
> m. 9913822582

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

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


Re: curl post vs. normal post?

2010-06-28 Thread LunarDraco
Does entering the same path 'http://localhost/api-test/1/0.2/users/
auth.xml' from a browser give you a different error.
I think you are right in thinking this is a routing problem, but I
would assume it is a routing problem higher up the chain with your
environment not with cake.
Meaning it would appear your http://localhost/ is pointing to a cake
deployment, and that you do not have a proper alias setup in (I'll
assume apache) for your 'api-test' to point to your specific cake
deployment. So the server is hitting your root cake folder and trying
to process the request and parsing for the api-test as a controller
instead of an app folder.

What is your web environment (server, default or root directory etc.)?
How many different cakephp apps are being hosted from your localhost?
what are their aliases etc.

On Jun 26, 1:14 pm, bsuichies  wrote:
> Situation: I'm building an API with cakePHP which holds user-accounts.
> I'd like to have multiple websites authenticating using this API by
> sending a post-request to the api and receiving the proper xml with
> user-info.
>
> To accomodate routing, I've added the following rule in routes.php.
>
>     Router::connect('/:channel/:version/:controller/:action/*',
>                     array('prefix' => 'api', 'api' => true),
>                     array('channel' => '[0-9]+'),
> array('version'=>'[0-9]+\.[0-9]+'));
>
> I've also created a form that holds all the necessary information
> (username + password) and tested this. This works. However, I'd like
> to use cURL to form a post-request & receive the information. For
> this, I created the code below.
>
>     $api_url = 'http://localhost/api-test/1/0.2/users/auth.xml';
>     $api_token = 'xx';
>     $url = $api_url.'?token='.$api_token;
>     $data = array('user' => $user, 'password' => $password);
>     $ch = curl_init($url);
>     curl_setopt ($ch, CURLOPT_POST, true);
>     curl_setopt ($ch, CURLOPT_POSTFIELDS, $data);
>     curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, true);
>     curl_setopt ($ch, CURLOPT_HEADER, false);
>     curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
>     $result = curl_exec($ch);
>     $error = curl_error($ch);
>     $info = curl_getinfo($ch);
>     curl_close($ch);
>
> This strangely doesn't work. The connection is working, but the
> routing appears to be failing, as the controller 'api-test' is called
> (which doesn't exist, this is my main-folder of my test-application)
> instead of the user-controller. I'm sure I must be missing something,
> but I can't figure out what that is.. I'm sure it's something between
> cURL and cakePHP, as a normal form works as intended. Anyone got any
> advice?

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

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


Re: validating login data fails because of md5

2010-06-21 Thread LunarDraco
I would check what data is in your $this->data before you do the find.
I see in your select that the 'email' field came across but is there
appropriate data in your password field.

Beyond that is there any reason your not using the Auth component?
if ($this->Auth->login($this->data))

On Jun 20, 4:20 am, Tomfox Wiranata  wrote:
> hi,
>
> i have a problem. i am saving the users password at registration as
> md5.
> when the user is trying a login, i check if the entered username and
> password is  equal to the entry in the database. for that, i have to
> convert the entered password into md5, to make it comparable:
>
> thats the code to find the user in my controller class
>
> [CODE]
> $user = $this->User->find(array('email' => $this->data['User']
> ['email'], 'password' => md5($this->data['User']['password'])),
> array('id', 'email'));
>             if(empty($user) == false)
> [/CODE]
>
> now if print the query to check what it looks like, one thing is odd.
> no matter what password i enter it is ALWAYS(!) the same md5 key:
>
> [CODE]
> SELECT `User`.`id`, `User`.`email` FROM `users` AS `User` WHERE
> `email` = 't...@web.de' AND `password` =
> 'd41d8cd98f00b204e9800998ecf8427e' LIMIT 1
> [/CODE]
>
>  no wonder i get no results and the variable "$user" is empty...i get
> "d41d8cd98f00b204e9800998ecf8427e" everytime..
>
> thats a mysterydoes somebody know the answer? i'd be s happy
>
> many many thanks
>
> btw: thats my view
>
> [CODE]
> 
> Login
>     create('User', array('action' => 'login'));?>
>         input('email');?>
>         input('password');?>
>         submit('Login');?>
>     end(); ?>
>  [/CODE]

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

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


Re: Validation - specifying which rules to use

2010-06-16 Thread LunarDraco

I think supporting that would move the business rules out of the model
and dirty up the controller. If you look at his second method of usage
you can specify a completely different validation set which still
lives in the model. This named validation can have a different set of
fields as well as rules to apply or to ignore. This keeps the model
fat and data centric and gives the controller the option to choose
which set of the model's validation to use. This also makes it cleaner
to test the validation.
On Jun 16, 6:37 pm, calvin  wrote:
> That's pretty clever. Though it would still be nice to have a way to
> simply specify which rules to ignore/use--the same way that you can
> specify which fields to validate.
>
> On Jun 16, 8:36 am, LunarDraco  wrote:
>
>
>
> > There are ways to deal with this, often times you need to use
> > different validation rules for adding a new record vs updating an
> > existing record. Or sometimes as an administrator you want to be able
> > to override the validation that is to take place.
>
> > Jonathan Snook has posted a pattern of using the multiple validations
> > based on the controller action that is being called. So it is very
> > possible to do what you are looking for.
> > His article is here and should get you moving in the right direction.
> > If its not a perfect fit, it will at least give you some ideas around
> > how to specify multiple validations and then select the correct
> > validation for the current 
> > use.http://snook.ca/archives/cakephp/multiple_validation_sets_cakephp/
>
> > On Jun 15, 7:45 am, WhyNotSmile  wrote:
>
> > > Is there any way to validate on a restricted set of rules in the
> > > controller?
>
> > > For instance, I have an email address which is validated in the model
> > > like this:
>
> > > var $validate = array(
> > >      'email' => array(
> > >          'maxlength' => array(
> > >              'rule' => array('maxLength',100),
> > >              'message' => 'Email address must be 100 characters or
> > > less'
> > >           ),
> > >           'notEmpty' => array(
> > >               'rule' => 'notEmpty',
> > >               'message' => 'Please enter your email address'
> > >            ),
> > >           'validEmail' => array(
> > >               'rule' => array('email', false),
> > >               'message' => 'Please enter a valid email address'
> > >            ),
> > >           'unique' => array(
> > >               'rule' => array('isUnique', false),
> > >               'message' => 'This email address has already been
> > > registered.  If you have forgotten your password, you can get a
> > > reminder by clicking on the link on the login page'
> > >            )
> > >      )
> > > )
>
> > > At one point I want to validate an email address, but I don't want to
> > > check that it's unique (because I'm not actually saving it, just
> > > checking it's otherwise valid).
>
> > > So far I have:
>
> > > if($this->User->validates(array('fieldList' => array('email' {
> > >  ...
>
> > > }
>
> > > Is there any way to define which rules I want it to validate against,
> > > or does it have to do all of them?  I can't find anything on this in
> > > the validation section of the manual (using v.1.2), so any directions
> > > would be much appreciated.
>
> > > Thanks.

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

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


Re: Validation - specifying which rules to use

2010-06-16 Thread LunarDraco
There are ways to deal with this, often times you need to use
different validation rules for adding a new record vs updating an
existing record. Or sometimes as an administrator you want to be able
to override the validation that is to take place.

Jonathan Snook has posted a pattern of using the multiple validations
based on the controller action that is being called. So it is very
possible to do what you are looking for.
His article is here and should get you moving in the right direction.
If its not a perfect fit, it will at least give you some ideas around
how to specify multiple validations and then select the correct
validation for the current use.
http://snook.ca/archives/cakephp/multiple_validation_sets_cakephp/


On Jun 15, 7:45 am, WhyNotSmile  wrote:
> Is there any way to validate on a restricted set of rules in the
> controller?
>
> For instance, I have an email address which is validated in the model
> like this:
>
> var $validate = array(
>      'email' => array(
>          'maxlength' => array(
>              'rule' => array('maxLength',100),
>              'message' => 'Email address must be 100 characters or
> less'
>           ),
>           'notEmpty' => array(
>               'rule' => 'notEmpty',
>               'message' => 'Please enter your email address'
>            ),
>           'validEmail' => array(
>               'rule' => array('email', false),
>               'message' => 'Please enter a valid email address'
>            ),
>           'unique' => array(
>               'rule' => array('isUnique', false),
>               'message' => 'This email address has already been
> registered.  If you have forgotten your password, you can get a
> reminder by clicking on the link on the login page'
>            )
>      )
> )
>
> At one point I want to validate an email address, but I don't want to
> check that it's unique (because I'm not actually saving it, just
> checking it's otherwise valid).
>
> So far I have:
>
> if($this->User->validates(array('fieldList' => array('email' {
>  ...
>
> }
>
> Is there any way to define which rules I want it to validate against,
> or does it have to do all of them?  I can't find anything on this in
> the validation section of the manual (using v.1.2), so any directions
> would be much appreciated.
>
> Thanks.

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

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


Re: Set format for DATETIME in model

2010-06-14 Thread LunarDraco
Why do you care about the format of the data in the data array?

The only time format of the date time should really matter is for
display.
And for display you should use the Time Helper in your views. It has
many functions for presenting date time. And if you need to you can
create your own class deriving from TimeHelper to add additional
functions.

Beyond that for my forms, I allow an open text entry for date time and
then use validation and php strtotime and date functions in my before
save to make sure the format is correct for the db.

In both cases the code is in the correct place display formating done
in the view. Data manipulation for storage done in the model.
I would not format the data in the array, I've had many times where
for one view, say an index, I want the short date displayed with no
time. And another view, say the detail of a single record of the same
model data I want to display the date and time using relative words
from the current date time, as in "18 hours and 22 minutes ago".

Keep the formatting of the display in the view, keep validation and
string input to modal format in the model, you'll be much happier down
the road if you do.

In my model I use code like the following to set the date based on
manual inputs as well as to post offsets from a given date:
$newdata['ContactEvent']['startdate'] =
$date_parse(date("c",strtotime("+$days days",$basestartdate)));

This one happens to be for setting the startdate of an event sometime
in the future based on the number of days.

In my views I also use a supporting javascript dropdown, this is not
required but it helps with bonds limiting etc.
http://www.frequency-decoder.com/2006/10/02/unobtrusive-date-picker-widgit-update
It has many options which can be set when creating the control in the
view based on other dynamic data. Here is a simple example of how I
use it for inputs:
$duedateClass = 'format-m-d-y divider-dash highlight-days-07 range-
low-'.date("Y-m-d",strtotime('last month')).' range-high-'.date("Y-m-
d",time()+(86400*365));
echo $form->input('completed', array(
'label' => 'Batch Completed',
'type' => 'text',
'size' => '15',
'class' => $duedateClass,
'error' => 'Completed date must be a date after 
'.date("m-d-
Y",time()).' and in the format "MM-DD-"'));

On Jun 13, 10:28 am, Jonas  wrote:
> I am on a cake v1.2 system so I don't think I have access to
> virtualFields...guess I have to get the [0] index and then use a
> helper to format the data...
>
> On Jun 11, 6:46 pm, calvin  wrote:
>
> > You're going to have to use the virtualFields model property.
> > Otherwise, it will always place it under a 0 index (even if you
> > specify the virtual field in the find as 'Model.field'). Otherwise,
> > just use a helper or the PHP date() function.
>
> > On Jun 11, 7:29 am, John Andersen  wrote:
>
> > > As far as I understand from the manual, then CONVERT means that you
> > > cast the date into another type, not converting the date into another
> > > format.
>
> > > Use DATE_FORMAT(date, format) instead!
> > > Enjoy,
> > >    John
>
> > > On Jun 11, 4:26 pm, Jonas  wrote:
>
> > > > What is the correct way of setting how I want the date returned from a
> > > > database Model->find ?
>
> > > > Without anything set it returns [createdate] => Jun 11 2010
> > > > 03:08:12:283PM which is not the format I'd like.
>
> > > > If I modify the column name to i.e. convert(varchar(26), createdate,
> > > > 126) as createdate I get the correct format but the result is returned
> > > > as:
>
> > > > [id] => 1,
> > > > [text] => 'Hello',
> > > > [0] => Array(
> > > >    [createdate] => '2010...'
> > > > )
>
> > > > which is not what I'd like either.
>
> > > > Thanks!
>
> > > > /Jonas

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

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


Re: Duplicate Queries in MODEL->HABTM->HABTM->HasMany relationship

2010-06-09 Thread LunarDraco
I agree with John,

And I would personally use a join query in this type of situation.
Your most likely not going to need all of the data that comes back
from normal cake binding. And normal cake binding is going to perform
multiple queries to obtain the data (this is not a bad thing, but it
does need to be understood). I've found anytime your digging that deep
into the data relations your also going after a fairly narrow slice of
the data. Joins will give you the exact data you need with a minimal
number of queries.

I've had a couple situations where I needed all the data from the
deepest relation. In this case I made a design change at the view
level and was able to break up that information into page-able sets so
the amount of data from any one query was limited.

I use to get quite frustrated with the number of queries and binding/
unbinding etc that was needed to get the data out of the models. To
the point of often writing functions in the model that would build a
sql select and execute it with a call to query(). I finally took the
time to really read and understand both containable, and how joins
work and have since gone back through the code and replaced all the
query calls with properly structured options arrays and find().

While reading about Containable keep in mind it is primarily a wrapper
around bind/unbind. So containable probably won't help you much for
performance on this issue as it will still generate many queries
(probably more than 144 separate queries in your case). See this
article which explains the problem with using containable in deep
relations.
http://www.endyourif.com/cakephp-containable-statement-pitfalls/

I still build up and test my sql statements by hand, then I figure out
weather I should use containable, joins, or both in some cases. When
at all possible I prefer to use containable because it is very simple
to read and understand.

A couple of questions to ask yourself when using joins is: "Are we
joining the data to filter the data or are we joining the data to
display some fields of the joined data? Do we need to display fields
from both/multiple tables in the join?" These questions are somewhat
important because of the way joined data is returned in the array. You
will want to write your join queries so the table which you want to
display fields from is the first table and then join the additional
tables for filtering. In other words its not always a top down select,
sometimes the data you really want is at the bottom and you only need
the parent model for filtering.

On Jun 8, 7:01 am, John Andersen  wrote:
> This is a frequent topic, retrieving data from models over several
> levels of association.
>
> The current answers nearly always are:
>
> 1) Look into using the Containable behavior, 
> see:http://book.cakephp.org/view/1323/Containable
>
> 2) Look into using joins, see:http://book.cakephp.org/view/1047/Joining-tables
>
> The above should make it possible for you to avoid the additional
> queries.
> Enjoy,
>    John
>
> On Jun 8, 1:10 pm, pinker42  wrote:
>
> > Hi,
>
> > i urgently need some help with a really nasty problem.
>
> > I have 4 main tables A,B,C,D and two join tables AB, BC joined: A (1
> > record) -> (HABTM AB) B (13 records) -> (HABTM BC) C (131 records) ->
> > (hasMany) D (405 records). When i fetch the data with A->find('All')
> > cake does a good job for A,B and C. But than repeats the Query for D
> > 13 times (number of records for B !).
> > The result set is okay, but the performance is really sad, because the
> > result set for D is quite Huge. Is it not possible to handle 
> > MODEL->HABTM->HABTM->HasMany releationships with simple model binds in
>
> > Cake ?
>
> > Best regards and thanks in advance
>
> > Dirk

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

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


Re: User errors and fat model, skinny controller

2010-06-09 Thread LunarDraco
You might want to take a look at the Loggable Behavior it has some of
what your looking for in logging usage info.
http://bakery.cakephp.org/articles/view/logablebehavior

There is also a WhoDidIt behavior which only logs who created/modified
a specific record. I didn't care for this method as it required db
structure changes to all models I wanted to log.
http://bakery.cakephp.org/articles/view/whodidit-behavior-automagic-created_by-and-modified_by-fields


On Jun 8, 10:09 am, calvin  wrote:
> Thanks for your reply. It's good to know that I'm on the right track.
> I guess part of what was tripping me up was wanting to have high-level
> Model functions when in actuality some of them belonged in the
> controller since they contained application flow logic/requirements.
> And I've also decided that returning a mixed data array with some kind
> of a status structure is the best way to go. I'm also in the process
> to implementing an event logger in my application to track errors,
> anomalous conditions, and possibly usage patterns.
>
> It's also interesting that you mentioned your method for importing CSV
> data as an example as that's the exact problem I was working on when I
> wrote the original post. I haven't tried offloading data processing to
> a background task, but I may have to investigate that approach as some
> of my CSV spreadsheets can take quite a while to process as well (it's
> an intranet app, so I just increase the max script execution time). By
> the way, you wouldn't happen to have found a way to import .xls (Excel
> spreadsheet) data have you? My data sets (sales data from various
> distributors) almost always comes in the form of Excel xls
> spreadsheets or, occasionally, Excel html spreadsheets. The html
> spreadsheets are pretty easy to deal with since they're just HTML
> tables with some proprietary tags and attributes, but as yet I've
> found no way to process or automatically convert XLS data to something
> readable like CSV.
>
> On Jun 7, 9:06 am, LunarDraco  wrote:
>
> > I've been using fat model for a while now. It was difficult for me to
> > get over what now appear to insignificant problems but at the time
> > they looked huge.
>
> > As the model's primary responsibility is to deal with data, I found it
> > useful to always return something more than a boolean. So most of my
> > model functions return a mixed data array.
> > Part of that result array is a status structure which I can then refer
> > to from the controller to display errors or redirect etc. This also
> > allows the model to process a set of data and return an iterative list
> > of errors. As an example I have a csv import which will process the
> > first 100 rows of an import. Each row has the potential of creating an
> > error, and the loop moves on to the next row. all these errors are
> > returned in a single result. The model then passes the file to a
> > background task to process the remainder of the rows. The controller
> > displays via the view to the user the results of the first 100 rows
> > along with the list of errors. I did this because some of these files
> > are huge and would timeout. I can process 100 rows fairly quick and
> > return control back to the user where they can see those newly
> > imported records along with any errors.
>
> > A second reason for this process is the model code doesn't know if it
> > is being called by human interaction or via a cron script in either
> > case the errors are also written to a logger which the user can review
> > at any point in the app.
>
> > In a previous post to this thread you mentioned you needed to redirect
> > in certain conditions. Don't get your business logic (model) confused
> > with your application flow (controller). A lighter controller doesn't
> > mean there isn't any logic in those functions it just means there is
> > less logic in them. Logic to control redirects definitely does belong
> > in the controller and your model needs to be able to give enough
> > information back to the controller to make those decisions.
>
> > I've also found building test for the models is a lot easier than for
> > the controller. If your using test do your best to write the test
> > first. If your not using test, at least think in the mindset of the
> > model code being called from human interaction as well as from a
> > headless script. This will force you to deal with errors in a batch
> > mode instead of one off exceptions.
>
> > Overall your on the right track your making your model fat and you
> > have identified the model is too deep for dire

Re: User errors and fat model, skinny controller

2010-06-07 Thread LunarDraco
I've been using fat model for a while now. It was difficult for me to
get over what now appear to insignificant problems but at the time
they looked huge.

As the model's primary responsibility is to deal with data, I found it
useful to always return something more than a boolean. So most of my
model functions return a mixed data array.
Part of that result array is a status structure which I can then refer
to from the controller to display errors or redirect etc. This also
allows the model to process a set of data and return an iterative list
of errors. As an example I have a csv import which will process the
first 100 rows of an import. Each row has the potential of creating an
error, and the loop moves on to the next row. all these errors are
returned in a single result. The model then passes the file to a
background task to process the remainder of the rows. The controller
displays via the view to the user the results of the first 100 rows
along with the list of errors. I did this because some of these files
are huge and would timeout. I can process 100 rows fairly quick and
return control back to the user where they can see those newly
imported records along with any errors.

A second reason for this process is the model code doesn't know if it
is being called by human interaction or via a cron script in either
case the errors are also written to a logger which the user can review
at any point in the app.

In a previous post to this thread you mentioned you needed to redirect
in certain conditions. Don't get your business logic (model) confused
with your application flow (controller). A lighter controller doesn't
mean there isn't any logic in those functions it just means there is
less logic in them. Logic to control redirects definitely does belong
in the controller and your model needs to be able to give enough
information back to the controller to make those decisions.

I've also found building test for the models is a lot easier than for
the controller. If your using test do your best to write the test
first. If your not using test, at least think in the mindset of the
model code being called from human interaction as well as from a
headless script. This will force you to deal with errors in a batch
mode instead of one off exceptions.

Overall your on the right track your making your model fat and you
have identified the model is too deep for direct human interaction. I
think there are many ways to deal with this without breaking the MVC
pattern.

My method explained above may seam too much for some, but having the
errors logged and being able to review them has helped in identifying
pieces of code which were in need of rework. A type of live profiling.
Not so much of the performance but more so on quality and intuitive
use or to identify poor assumptions on my part about the ability of my
users.

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

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


Re: how to activate child afterDelete callbacks when i delete parent model?

2010-06-03 Thread LunarDraco
The model call backs are only executed for the model being called and
not for the associated models that might also be effected by the call.
See the manual http://book.cakephp.org/view/76/Callback-Methods
"Please note that these callbacks are not called when dealing with
associated models; callbacks are only executed for the main model of a
query."

I would add a function to the Child model of cleanupImages().
Then in the Parent afterDelete iterate the children and call the
cleanupimages function.

afterDelete may be too late and you might need to deal with this in
the beforeDelete of the parent depending upon what info from the child
you need to properly clean up the images.


On Jun 2, 3:06 am, Kei Simone  wrote:
> hi,
>
> i have a parent model that hasMany child models.
>
> when the child model is deleted, i need to delete the images
> associated with the child model.
>
> hence i want to place it in the afterDelete callback of the child
> model.
>
> now the association of parent with child is like this:
>
> var $hasMany = array(
>                 'Child' => array(
>                         'className' => 'Child',
>                         'foreignKey' => 'parent_id',
>                         'dependent' => true,
>                         'conditions' => '',
>                         'fields' => '',
>                         'order' => '',
>                         'limit' => '',
>                         'offset' => '',
>                         'exclusive' => true,
>                         'finderQuery' => '',
>                         'counterQuery' => ''
>                 ),
>
>         );
>
> how do i activate the child afterDelete when i delete parent?

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

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


Re: Unitesting with Simpletest

2010-05-21 Thread LunarDraco
Exactly what are you trying to test?
It looks like your trying to test the http POST and response
protocols, I'm pretty sure Apache and other web server engines have
fully tested those.

First make sure your logic is as deep into the model as possible. As
models are much easier to test than controllers.
The rest of this sounds like your testing the controller. The
controller is not exactly simple to test against however it can be
done. And you may need to use a few different MOCK objects to get the
results your looking for.

Mark Story has a couple of articles on how to test the controllers.
There is a bit of setup involved and you may have to create some mock
objects to accomplish the test.

http://mark-story.com/posts/view/testing-cakephp-controllers-the-hard-way
http://mark-story.com/posts/view/testing-cakephp-controllers-mock-objects-edition

On May 20, 9:17 am, Aung  wrote:
> Hi team,
>
> I have been using cakephp for one of my projects and we are trying to
> test with Simpletest as provided in the documentation. However, our
> api cannot be called directly. We have to use
>
>     * Method: POST
>     * Header Name: Content-Type
>     * Header Value: application/x-www-form-urlencoded
>     * Body: params={"username":"aung","password":"pass"}
>
> I can solve the first problem by using 'method'=>post in testAction()
> method from CakeTestCase as 
> inhttp://book.cakephp.org/view/366/Testing-controllers
> page. However, i don't have any idea how to set the header name, type
> and params into the body. We can use httpclient to do these things but
> httpclient is a bit manual and we think simpletest in cakephp
> framework is better if we can solve this problem.
>
> If anyone knows, please let me know the solution :) ..
>
> Thank very much in advance.
>
> Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with 
> their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group 
> athttp://groups.google.com/group/cake-php?hl=en

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

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


Re: Keeping a history of changes without composite keys

2010-05-19 Thread LunarDraco
You may gleam some insight on how this could be done from the Revision
Behavior. I'm not sure the behavior will give you exactly what you
need, but it may at least give you some ideas of how to implement what
you need.

http://bakery.cakephp.org/articles/view/revision-behavior-revision-control-made-easy


On May 18, 12:16 pm, shantamg  wrote:
> Hi,
>
> Please excuse the long post... I tried to give a concise question, but
> also I felt the need to give an example and explain...
>
> I need to store a history of database changes (i.e. copies of all of
> the fields [with their same ids] grouped by a publish date), and I'm
> having trouble designing the database to work with cake.
>
> Here are some tables:
>
> areas
> shifts
> people
> people_shifts
>
> Area hasMany Shift,
> Shift HABTM People.
>
> So, each area has shifts, and then people are scheduled for those
> shifts. The user who is making changes would be working on a staging
> copy and would then "publish" the changes, giving that set of data a
> new publish_id). In my mind, every table would have a foreign key to
> the publishes table, and when the whole thing is "published" all of
> the data would be put in there with a new publish_id. In effect, it is
> like copying the whole database inside of itself using a reference
> table for each set of data.
>
> This would work, but I want to be able to track shifts/areas/people
> back through time so they need a consistent id. If I wasn't using
> cake, I'd use a composite key (publish_id, id)
> I know cake does not ever plan to support composite keys and I totally
> understand why. This leaves me with the question of how to implement
> this in cake?
>
> If I just give every table an extra id for cake then there's my unique
> key, but then how will I keep the model relationships? I want to be
> able to say, for example:
>
> we are on publish #42
>     area #1 has shifts #1 and #2 and
>     person #1 is doing shift #1 etc...
> then...
> let's look at publish #43
>     area #1 has shifts #1 and #2, plus a new shift #3
>     person #1 is now doing shift #3
>
> If I let cake use an id that is unique, then how can I keep the
> relationships between models intact?
>
> Thanks so much for your support,
> Jason
>
> Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with 
> their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group 
> athttp://groups.google.com/group/cake-php?hl=en

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

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


Re: Sessions working in one controller and not the other

2010-05-05 Thread LunarDraco
How do you have sessions configured. Are you using php, cake or
database sessions?


On May 4, 2:17 pm, LordZardeck  wrote:
> Adding still doesn't help. I REALLY need to figure this out. its so
> wierd because the sessions work when you add var $uses = array(), even
> when I don't have the Session componet added! its not even in the
> app_controller!
>
> On May 4, 10:42 am, thatsgreat2345  wrote:
>
>
>
> > Not a clue, would have to look into the core for that. But either way
> > just add var $components = array('Session'); to both of them.
>
> > On May 3, 7:21 pm, LordZardeck  wrote:
>
> > > Ok, I found out that the problem arises when I use a model. When I set
> > > the $uses varibale to an empty array, it works. What would cause this?
>
> > > On May 3, 6:21 pm, thatsgreat2345  wrote:
>
> > > > Include the session component
>
> > > > On May 3, 3:59 pm, LordZardeck  wrote:
>
> > > > > For some reason, the session handling works in one controller and not
> > > > > the other. I can't figure out why. I am using CakePHP 1.2.5.
>
> > > > > //
> > > > > //Does work
> > > > > //
>
> > > > > sessions_controller.php:
>
> > > > > class SessionsController extends AppController {
> > > > >     var $name = "Sessions";
> > > > >     var $layout = "ajax";
> > > > >     var $uses = array();
>
> > > > >     function create(){
> > > > >         if($this->Session->read('Data') == null){
> > > > >             $this->Session->write('Data', rand());
> > > > >         }
> > > > >         $this->set('data', $this->Session->read('Data'));
> > > > >         $this->set('SessionID', $this->Session->id());
> > > > >     }
>
> > > > > }
>
> > > > > create.ctp:
> > > > > $msgJson["SessionID"] = $SessionID;
> > > > > $msgJson["data"] = $data;
> > > > > echo json_encode($msgJson);
> > > > > //results in ({"SessionID":"sd8s8o32edmjnjt94ouse99fd2","data":19409})
> > > > > every time (parenthesis not in result)
>
> > > > > //
> > > > > //Doesn't Work
> > > > > //
>
> > > > > messages_controller.php:
>
> > > > > class MessagesController extends AppController {
>
> > > > >     var $name = 'Messages';
> > > > >     var $layout = "ajax";
>
> > > > >     function listMessages() {
> > > > >         if($this->Session->read('Data') == null){
> > > > >             $this->Session->write('Data', rand());
> > > > >         }
> > > > >         $this->set('data', $this->Session->read('Data'));
> > > > >         $this->set('SessionID', $this->Session->id());
> > > > >         $this->set('messages', $this->Message->find("all",
> > > > > array("order"=>"priority ASC")));
> > > > >     }
>
> > > > > }
>
> > > > > list_messages.ctp:
>
> > > > > $msgJson["count"] = count($messages);
> > > > > $msgJson["SessionID"] = $SessionID;
> > > > > $msgJson["SessionData"] = $data;
> > > > > foreach($messages as $message){
> > > > >     $msg[] = $message["Message"];}
>
> > > > > $msgJson["items"] = $msg;
> > > > > echo json_encode($msgJson);
> > > > > /*
> > > > > results in ({"count":3,"SessionID":"","SessionData":27384,"items":
> > > > > [{"id":"4","priority":"3","subject":"Another
> > > > > message","message":"adsfasdf"},
> > > > > {"id":"2","priority":"3","subject":"testing again","message":"just
> > > > > seeing ow "},
> > > > > {"id":"7","priority":"3","subject":"asdgasdg","message":"asdfasdfasd"}]})
> > > > > except the SessionData changes everytime and the SessionID never shows
> > > > > up.
> > > > > */
>
> > > > > Any ideas what might be wrong?
>
> > > > > Check out the new CakePHP Questions 
> > > > > sitehttp://cakeqs.organdhelpotherswiththeir CakePHP related questions.
>
> > > > > You received this message because you are subscribed to the Google 
> > > > > Groups "CakePHP" group.
> > > > > To post to this group, send email to cake-php@googlegroups.com
> > > > > To unsubscribe from this group, send email to
> > > > > cake-php+unsubscr...@googlegroups.com For more options, visit this 
> > > > > group athttp://groups.google.com/group/cake-php?hl=en
>
> > > > Check out the new CakePHP Questions 
> > > > sitehttp://cakeqs.organdhelpotherswith their CakePHP related questions.
>
> > > > You received this message because you are subscribed to the Google 
> > > > Groups "CakePHP" group.
> > > > To post to this group, send email to cake-php@googlegroups.com
> > > > To unsubscribe from this group, send email to
> > > > cake-php+unsubscr...@googlegroups.com For more options, visit this 
> > > > group athttp://groups.google.com/group/cake-php?hl=en-Hidequotedtext -
>
> > > > - Show quoted text -
>
> > > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelpothers 
> > > with their CakePHP related questions.
>
> > > You received this message because you are subscribed to the Google Groups 
> > > "CakePHP" group.
> > > To post to this group, send email to cake-php@googlegroups.com
> > > To unsubscribe from this group, send email to
> > > cake-php+unsubscr...@googlegroups.com For more options, visit this group 
> > > athttp://groups.google.com/group/cake-php?hl

Re: Is it possible to write common code in one function and i have to call that function when i was required

2010-04-21 Thread LunarDraco
If the code is meant to transform or in some way CRUD or manipulate
data and it needs to be accessible from multiple controllers, I would
push it down to the model that it is associated with. then in your
code you can call the function as $this->SomeModel->myFunction();
Pushing the code to the model will simplify using it from any
Controller, and it simplifies writing test for the function as well.

MVC -- weight the code in the same order heavy (M)odel, medium (V)iew
and light on the (C)ontroller.

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

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


Re: Advice for personalized email (i.e. newsletter, mass email)

2010-04-16 Thread LunarDraco
tcornett,

Swift Mailer handles persistent connections. It also handles
throttling and secure connections to smtp.

I've yet to find a component/plugin/behavior that wraps swift mailer
or any other mailer in a way that takes advantage of persistent
connections and throttling features. However the Component is fairly
short and might be a good starting point to just re-write in a
function that can handle the looping while in one connection.
I've written a task which i call from a background queue that uses the
swiftmailer component. And swiftmailer is very complete and simple to
use. From my app I add a bunch of task to the queue. Then in the
background those task are pulled and processed. Each of my email
templates use a variable replacement where I can do a preg_replace
looking for patterns like {placeholder} and inject to that placeholder
new content. Currently i'm making a new connection for each email
using the swiftmailer component.

This has been sufficient for my needs up to this point, but I may have
to visit this issue sooner than later.
The component needs to be updated to make use of the persistent
connection and throttling. But this may be a good start for you. The
component does have a couple CallBacks, but I think it would need to
be augmented with a singleton reference to the active SwiftMailer
Object then you could easily check if a connection was already open
and continue to use it.

Queue background processing:
http://github.com/MSeven/cakephp_queue

SwiftMailer:
http://swiftmailer.org/

SwiftMailer Component:
http://bakery.cakephp.org/articles/view/updated-swiftmailer-4-xx-component-with-attachments-and-plugins

On Apr 15, 4:36 pm, tcornett  wrote:
> I am looking to setup an aspect of my cakephp application to handle
> the emailing of a large number of individuals with a personalized
> email message. [THIS IS NOT FOR SPAM]  I have been looking around and
> I cant really seem to find anything that handles this situation well.
>
> A couple of the major roadblocks that I have run into are :
>  1) Persistent connection with the SMTP server.  Instead of connecting
> for one message, I need to be able to connect, send X emails, and then
> disconnect.  There does not seem to be anything out there for this
> type of behavior
>  2) The need for personalization in each email.  It can not be 1 email
> with 50 recipients.  It would end up being 50 emails each with
> different information in the body of the email.
>  3) Request timeout - If I try to send them all at once, the request
> will time out.  I would rather have a setup where an automated process
> picks up the email and sends them.
>
> I have looked into CRON jobs based solutions, found basic queue and
> deferring processing techniques but nothing really handles this
> situation, IMHO is a pretty basic problem for any application with
> users.  I know I am basically building a mailing list manager but it
> is just going to be one aspect of the app.
>
> Does anyone have any directions to point me in or ideas for solutions?
>
> Thanks in advance for any help.
>
> Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with 
> their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group 
> athttp://groups.google.com/group/cake-php?hl=en

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

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


Re: Retrieving objects from the DB instead of arrays

2010-04-02 Thread LunarDraco
As Waither mentioned you need to fatten your model. And make your
controller thin.

You requested an object that represents your data. And the model is
that object. It should return the data in an appropriate structure for
your view. Any manipulation of that data should be done in the model.

If you have a lot of conditional code in your controller modifying/
morphing the data you can almost bet that code is in the wrong place.
Especially if your next thought is how do I reuse this controller
function from another function.

I think the biggest hurdle coming into cake from a non MVC background
is getting your head wrapped around (M)odel. I believe the order of
the acronym has some meaning (M)odel, (V)iew, (C)ontroller and that
meaning is the importance and weight of the stack. Heavy on the model
then the view with the controller as the lightest.
The model represents our Application Data and is tied to the DB as our
Storage Data but it is not a one to one field mapping of the table and
sometimes isn't even tied to a db or table. Sure it most often starts
that way as a baked model, but the model object is where most of your
code should be that deals with transforming your Application Domain
Data to and from the DB Storage Data. It is really the business logic
of the data. It is the exact object you requested.

The Model should know how to deal with the data and provide to the
view exactly what it needs. You should not have to write additional
code outside the model to adjust and tweak the data before it goes to
the view.

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

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

To unsubscribe, reply using "remove me" as the subject.


Re: Custom flash messages

2010-04-02 Thread LunarDraco
In your first post it looks like you may have had the closing ')' in
the wrong place, and the array was being passed as a second parameter
to the __() function and was never getting to the setFlash function.
You had:
$this->Session->setFlash(__(' Some Flash message here ',array('class'
=> 'flash_failure')));
In your more recent post has all three params for the setFlash message
and is not using the __().
but you probably could have restructured your first format as:
$this->Session->setFlash(__(' Some Flash message
here'),'default',array('class' => 'flash_failure'));

On Apr 2, 11:04 am, Ed Propsner  wrote:
> It works now but I'm not sure what I was doing wrong ... I don't even know
> what I did to fix it.
>
> I was using this so set my message [code]  $this->Session->setFlash(' Some
> message here ', 'default', array('class' => 'flash_failure'));  [/code]
>
> The CSS was simple enough as well    [code]    .flash_failure { //some css }
>      [/code]
>
> It kept assigning the class "message" to the div no matter which way I tried
> to write it.
>
> - Ed
>
> On Fri, Apr 2, 2010 at 11:55 AM, cricket  wrote:
> > Maybe your CSS selector needs to be adjuted. Do you have firebug
> > installed? Easy enough to check with that, whether it's the CSS or the
> > div isn't getting the class name.
>
> > On Apr 2, 11:22 am, Ed Propsner  wrote:
> > > Seems straightforward enough but I must be overlooking something
> > somewhere.
> > > Still not working out for me.
>
> > > On Fri, Apr 2, 2010 at 6:22 AM, WebbedIT  wrote:
> > > > I use:
>
> > > > $this->Session->setFlash('Whatever message I want to display',
> > > > 'default', array('class'=>'message update'));
>
> > > > And I change the update class to notice or error depending on what
> > > > info I am displaying.  My CSS is as follows
>
> > > > div.message {-moz-border-radius:5px; padding:6px 10px; margin:10px 0;
> > > > text-align:center;}
>
> > > > div#authMessage, div.message.error {color:#f00; background:#FFE6E6;
> > > > border:1px solid #FF9D9D;}
> > > > div.message.update {color:#090; background:#ECFFEC; border:1px solid
> > > > #090;}
> > > > div.message.notice {color:#DFD137; background:#FFFBCF; border:1px
> > > > solid #DFD137;}
> > > > div.message.site {font-size:90%; color:#090; background:#ECFFEC;
> > > > border:1px solid #090;}
> > > > div.message.site a {color:#090; font-weight:bold;}
>
> > > > Cricket's implementation looks interesting though.
>
> > > > HTH
>
> > > > Paul
>
> > > > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp
> > others
> > > > with their CakePHP related questions.
>
> > > > You received this message because you are subscribed to the Google
> > Groups
> > > > "CakePHP" group.
> > > > To post to this group, send email to cake-php@googlegroups.com
> > > > To unsubscribe from this group, send email to
> > > > cake-php+unsubscr...@googlegroups.com
> > >For
> > more options, visit this group at
> > > >http://groups.google.com/group/cake-php?hl=en
>
> > > > To unsubscribe, reply using "remove me" as the subject.
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others
> > with their CakePHP related questions.
>
> > You received this message because you are subscribed to the Google Groups
> > "CakePHP" group.
> > To post to this group, send email to cake-php@googlegroups.com
> > To unsubscribe from this group, send email to
> > cake-php+unsubscr...@googlegroups.comFor
> >  more options, visit this group at
> >http://groups.google.com/group/cake-php?hl=en

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

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


Re: cakephp doesn't support template?

2010-03-23 Thread LunarDraco
Definition from home page of phpframeworks says:
Templates: Indicates whether the framework has an inbuilt template
engine.

On Mar 22, 12:03 pm, Bryan Lim  wrote:
> Hi all,
>
> I wonder what does it mean by cakephp doesn't have "template" ?
> refer:http://www.phpframeworks.com/php-frameworks/index.php?id=2
>
> Thanks,
> Bryan

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

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

To unsubscribe from this group, send email to 
cake-php+unsubscribegooglegroups.com or reply to this email with the words 
"REMOVE ME" as the subject.


Re: Basic Auth & REST = Blackhole

2010-03-22 Thread LunarDraco
The other potential problem is with the Security Component the Posted
data needs to match what was sent out to the browser as the form data.
When a from is created with Security Component enabled, the form
creates a hidden field with a hashed data. This is checked on the post
and black holed if it doesn't match.

Since your posting via REST you probably don't even have the hashed
data field in the posted data. I'm not sure exactly how to get around
this or if the Security Component is aware the Post is a Restful post
to do different logic. http://book.cakephp.org/view/175/Security-Component

Not sure exactly why you think you Need the Security Component for
Basic Auth. Basic Auth is available from the 'Auth' Component. I don't
think you need both to accomplish your end goal of a Secure Rest
service.

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

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

To unsubscribe from this group, send email to 
cake-php+unsubscribegooglegroups.com or reply to this email with the words 
"REMOVE ME" as the subject.


Re: Basic Auth & REST = Blackhole

2010-03-22 Thread LunarDraco
Try setting security level to low. If that works your session is
probably being reset do to the Host name at the PHP level from the
setting session.referer_check which is set for both medium and high
security levels.

On Mar 21, 12:25 pm, SonnyBurnette  wrote:
> I am trying to add a few light restful API methods to my app. In order
> to secure this, I plan to use basic auth with SSL. The problem I have
> now is the security component wants to blackhole the POSTed data since
> I enabled the security component for basic auth.
>
> What do I need to do to keep these methods secure and allow the data
> from a remote client to be added?

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

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

To unsubscribe from this group, send email to 
cake-php+unsubscribegooglegroups.com or reply to this email with the words 
"REMOVE ME" as the subject.


Re: Cake-Shell and Components

2010-03-19 Thread LunarDraco
This is how I have done it as well. The difference between the Shell
and the cake website is the Shell loads pretty much nothing for you.
The Cake Magic is fairly week at the shell level. I don't think that
is a bad thing, but you do have to load up and build bind your objects
using standard php techniques.

You might also want to look at http://github.com/MSeven/cakephp_queue
which could help with your overall goal of offloading process intense
events or background processing which has nothing to do with the UI
that needs to be returned to the user.


On Mar 18, 12:42 pm, amiable_indian  wrote:
> I am learning Cake Shells and thinking of using them where I want to
> offload the work asynchronously by calling multiple shell commands
> ( housekeeping ) from a controller and run them parallel in
> background, without making user to wait.
>
> From Shell I wanted to use existing Components which were doing part
> of the work that Shell needs to perform. These Components were coded
> earlier and have interdependencies with other Components defined using
> the way suggested in book :
>
> var $components = array('Dependency1',...);
>
> [ Based on 
> ::http://book.cakephp.org/view/787/Using-other-Components-in-your-Compo...
> ]
>
> This worked when I was calling component from other controllers,
> however now when I am calling the same component from Shell, it
> started giving me errors related to dependencies.
>
> To remove these errors, I had to import dependencies and create their
> objects before using them
>
> App::Import('Component','Dependency1');
> ..
> class MyComponent . {
> ..function initialize () {
> ..
> .. $this->Dependency1 = & new Dependency1Component();
> ..
> ..}
> ..
>
> }
>
> Now the code is working, but I just wanted to confirm with the
> community that what is the recommended practice.
>
> TIA,
>
> _amiable_indian_

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

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

To unsubscribe from this group, send email to 
cake-php+unsubscribegooglegroups.com or reply to this email with the words 
"REMOVE ME" as the subject.


Re: Auth losting authentication with no reason

2010-03-19 Thread LunarDraco
This often times has to do with how PHP's session is setup. The Cake
Session object is a wrapper class around the PHP Session so your still
using the servers session if you want to understand Cake's Session it
would be worth your time to learn the basics of php $_SESSION and what
can be done with it.

One common problem is if the link you are following is from a
different HOST the php session has a session.referer_check which is
set to the HTTPS_HOST for security high and to HTTP_HOST for security
medium, it is not set for security low. This causes the session to be
reset if the referer is not the host that is being called. In other
words if you followed a link from an email or some other server that
points to your app. This also presents when going back and forth
between the root app/domain and a root/sub app/domain because the the
HTTP_HOST can changes (if one site is using blah.blah.com and the
other is using localhost or ip address)
Often we all have code to read in a cookie to remember a user that has
previously logged in. This often just masks and hides the problem. So
we don't notice most of the time when the session was dropped until we
start to rely on a saved value that we thought we saved to the session
or when the user cookie expires and we are redirected to the login
page. So these often times appear very random when in reality they are
not. If your having what appears to be intermediate session lost, its
very likely its occurring more than you think. Some debugging is
needed.

The only difference I can determine between security medium and
security low is timeout duration and setting the php
session.referer_check. I was always concerned about using low, but
I've learned that medium and high only get in the way. So I use low
and deal with security measures in my app_controller to control which
referer I allow to access specific controller actions. This is better
anyway (for my app) as before it was all or nothing.

To monitor your session info and see when its changing I place some
log statements in my app_controller beforeFilter and or beforeRender.

$this->log(__CLASS__.'.'.__FUNCTION__.', line:'.__LINE__.', request:'.
$this->name.'.'.$this->action,LOG_DEBUG);
$this->log(__CLASS__.'.'.__FUNCTION__.', line:'.__LINE__.',
Session.id:'.$this->Session->id(),LOG_DEBUG);
$this->log(__CLASS__.'.'.__FUNCTION__.', line:'.__LINE__.',
Session.error:'.print_r($this->Session,true),LOG_DEBUG);

I use the third line to get some detailed debugging, one thing you'll
notice is the sessions error will be set to "Config doesn't exist" and
the Session will still be valid. With referer_check set or security
set to medium or high, any link pointing to your site from another
host will have this error and the session will restart on the
following redirect (which is valid behavior most of the time). This
was a problem for me as I was passing control from an asp server to a
cakephp server using a user token and telling Auth to log the user in.
The user would get logged in and then I would redirect to the intended
controller action at which point the session would reset and the user
would be asked to login anyways. Setting security to low cleared this
up.

I hope this helps some of you I know I spent two days debugging and
trying to understand exactly what was going on with my session. The
loggin mentioned above proved to be the most help. Be concerned if you
see alot of sessions with the error "Config doesn't exist" and try
setting security to low.

LunarDraco

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

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

To unsubscribe from this group, send email to 
cake-php+unsubscribegooglegroups.com or reply to this email with the words 
"REMOVE ME" as the subject.


Re: Cake rendering a time comment in views

2010-03-19 Thread LunarDraco
Configure::write('debug', 0);
at end of your layout.

in controller
$this->layout('JSON')

On Mar 19, 9:04 am, "Dr. Loboto"  wrote:
> Just make layout for JSON and set debug to 0 at the end of it.
>
> On Mar 19, 5:52 pm, nurvzy  wrote:
>
> > Yup, it does.  I pass back and forth a json object and if debug is > 0
> > I get an invalid json object because of the timestamp.
>
> > I've written two little functions I like to use for cleaning off that
> > timestamp for while I'm developing:  First I use if its an xml file I
> > want to parse, second is if I want to clean a json object in
> > particular since its a tad bit faster.
>
> > var CakeCleaner = {
> >   clearTimeStamp: function(text){
> >     var end = text.indexOf('

Re: Model Associations - just feels wrong

2010-03-19 Thread LunarDraco
The problem I see with your model is in your ZipLocation you have the
code set to a PK.

The Problem:
It is often thought that a zipcode belongs to only one city. And that
a city can have many zipcodes. There are no such rules in the postal
system.

One zip code could and often overlaps many city boundaries. Especially
in rural areas.
So your ZipLocation Table as it is defined could not have records like
the following without violating the PK:
84087, Woods Cross, UT
84087, West Bountiful, UT

I see this design quite a bit and this is where you will run into
trouble. But probably not until you get quite a ways down the path of
development and start adding a bunch of data.

You should follow the naming scheme for table names and special field
names like (id, [fkmodel]_id, name, description, created, modified)
this will help tremendously during the baking of your model as cake
will pick up all the appropriate hasOne, hasMany, belongsTo, etc. This
will also help in your building your forms for creating your dropdowns
and autofill text as if your models have a name field it is used in
the dropdown. I don't like to see user data stored in the PK. If you
need it to maintain uniqueness (which you don't want to in this case)
there are other ways to guarantee the user data is unique. PK and FK
should be for the data relations, and program use only.
I would review section 2.4 of the manual 
http://book.cakephp.org/view/22/CakePHP-Conventions
which talks about all of the file naming, model and database,
controller and view conventions.

Creating the tables as below allows you to have multiple cities in the
same zipcode and still maintain proper relations between the tables.
Your Model relations still remain as Location hasOne ZipLocation,
State hasMany ZipLocation, ZipLocations belongTo Locations, and
ZipLocations belongTo States. And your Form can display the proper
autofill selections when the user enters 84087 or any other zips that
might have multiple cities.

--
locations
--
id (PK)
name
street1
street 2
zip_location_id (FK)
...

--
zip_locations
--
id (PK)
zipcode (indexed)
city
state_id (FK)

--
states
--
id (PK)
code
name

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

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

To unsubscribe from this group, send email to 
cake-php+unsubscribegooglegroups.com or reply to this email with the words 
"REMOVE ME" as the subject.


Re: Delete Child Models

2010-03-18 Thread LunarDraco
If your wanting a more convenient method like model_A-
>deleteAllRelatedChildren($id).
You could build this function into your model or app_model and
recursively iterate the related structures calling the child model
deleteAll as John Andersen mentioned.


On Mar 17, 12:19 am, John Andersen  wrote:
> Yes, look at the models deleteAll method 
> at:http://book.cakephp.org/view/692/deleteAll
>
> Using your child model, call the deleteAll method with the conditions
> that all records with the parent id (the A) is to be deleted.
>
> Enjoy,
>    John
>
> On Mar 17, 6:49 am, guille1983  wrote:
>
> > is there a cake magic way to delete all children models of a given
> > model ? I just want to delete childs not the main model.
>
> > Let me explain it to you
>
> > Model A has many B, C, D -- hasOne E, F,  hasAndBelongsToMany G, H
>
> > I want to delete B, C, D, E, F, G, H and keep A

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

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


Re: PHP 5.3 open short tag does't working on cakePHP 1.2.6

2010-03-17 Thread LunarDraco
Not sure what editors your using but as soon as I type  leaving my cursor ready to enter php
commands.
I can't remember the last time I worried about typing to many chars.
Other than posts and email! ;)
I'm sure that some may complain that eclipse is a bloated IDE for
simple php editing, and they may be right. But I spend most of my day
in code (php, java, html, css, javascript, etc) and only launch the
app once a day at most, if for some reason I shut my machine down.


On Mar 16, 11:31 am, cricket  wrote:
> On Mar 16, 11:55 am, Marcelo Andrade  wrote:
>
>
>
> > The problem is not only the 6 more chars, but as open short tags are
> > deprecated (and AFAIK will be removed in php 6), if you insist using
> > it, you'll face this kind of problem when deploying you application in
> > other servers.
>
> This is the first I've heard that they are deprecated. That bites! I
> rather prefer them than the alternative. But I agree that they're a
> Bad Idea for any code that will not be under one's control.
>
> I don't use " use the former, actually.
>
> As for complaints about them making it more difficult to see, the
> problem would be fixed with better syntax highlighting. They appear
> just fine for me.
>
> For anyone who needs to convert to the ugly, full syntax, do not reach
> for regular expressions. That'll be a pain for anything other than the
> simplest files. A colleague once did this successfully using the
> methods described in the comments here:
>
> http://stackoverflow.com/questions/684587/batch-script-to-replace-php...

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

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


Re: Ideas to manage open voting

2010-03-17 Thread LunarDraco
I'd say without a login that is verified against a real email with a
postback token verification there is no real way to do this.
You could store a cookie in the browser, which could be cleared by the
user and re-vote.
You could tie it to the IP like you suggest, but the IP your server
see's is only the ip of the publicly visible router. There may be many
machines behind this one IP, And besides that its not the computer
thats voting its a person.
You could ask for personal information which everyone will just lie
about.

I've seen many voting designs. I've never heard of anyone trying to do
it open successfully. Every valid voting system has some way to
validate the user is real before they allow the vote.

I'd say if your really going to go down this path, associate the vote
with the IP address and a time duration say 1 day or 12 hours. That
would at least take care of someone scripting the vote. But you may
miss out on some votes and hopefully most people would not be
interested enough in sabotaging your results to put the effort into
visiting the vote every day.


On Mar 17, 2:04 pm, Amit  wrote:
> I'm working on a site that's going to let people vote on submissions.
> To encourage interaction I want to let anonymous users vote, but I
> still want to limit unique visitors to one vote. I know I won't be
> able ensure 100% adherence unless I require some sort of login, but
> allowing for this what should I check to see if a person has already
> voted?
>
> Is 1 vote/ip address good enough? Is there anything else should I log/
> track to prevent 1 person from voting multiple times (knowing full
> well that since it's open voting I can't stop every scenario)?

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

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


Re: Concept of seamless registration

2010-03-14 Thread LunarDraco
I think your going against the grain of web security issues.

All my banks, paypal, ebay, amazon etc. Have been training me and
everyone else on the web NOT to follow links in our emails to login to
our accounts. They suggest we manually type the URL and login to the
site with our known username and password.

For advanced users who know to inspect the link before clicking this
isn't much of a problem. But if you have novice users they are going
to be very leery about using such a system as it goes against the
security protocols they've already been taught by more pro-dominant
players on the web.

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

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


Re: 1 form & 2 submit buttons

2010-03-04 Thread LunarDraco
Here's a snippet of code I use
View:
echo $form->button('Save Only', array('type'=>'submit',
'name'=>'data[FormControl][save]','id'=>'SaveOnly',
'value'=>'saveonly'));
echo $form->button('Save-Email', array('type'=>'submit',
'name'=>'data[FormControl][save]','id'=>'SaveEmail',
'value'=>'save_email'));

Controller:
if($this->data['FormControl']['save'] == 'saveonly')

if($this->data['FormControl'['save'] == 'save_email')

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

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


Re: Multiple Select Question - Only add choices?

2010-03-04 Thread LunarDraco
the array('multiple'=>'checkbox') is a nice feature, but I think your
outside its intended use.
I ran into a simular situation.
I built a foreach loop that creates each checkbox individually.
In your case if your going to set the checked value you would also add
a disabled attribute.


On Mar 3, 12:58 am, TimG  wrote:
> Hey,
> I have a multiple select that is being displayed as checkboxes thanks
> to the "array('multiple'=>'checkbox')" code. I need to set it somehow
> so that users can only select new items. So they can check new
> checkboxes but not uncheck boxes that are already checked when the
> page loads.
>
> I figured out that my best bet is to disable the already selected
> boxes and then add a hidden field selecting them. What I don't know
> how to do is how to add the if statements so that when the form helper
> does its magic it'll render it like that.
>
> I can scrap the checkboxes if need be and just use a multiple select
> box... I just need to make it so the user can select items but not
> unselect the ones that are already selected. And I would prefer not to
> use JS. Better to do things server side.
>
> Any thoughts?

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

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


Re: How to save data in an different table than the controller table when no relations?

2010-03-04 Thread LunarDraco
One more item on this setup.
You can create relationships in your model to bind the temp records as
children to the original record.
To do this you create two relationships in the model.
var $belongsTo = array(
  'ParentBook' => array(
'className' => 'Book',
'foreignKey' => 'temp_id',
'conditions' => 'Book.temp_id is not null'));
and
var $hasMany = array(
'TempBook' => array(
'className' => 'Book',
'foreignKey' => 'temp_id'));

once this is in place you can use the containable behavior to include
or exclude the children or temp records.


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

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


Re: How to save data in an different table than the controller table when no relations?

2010-03-04 Thread LunarDraco
Chris, I would suggest keeping the data in the same single table Books
with a flag that identifies it is a temp record.
The way I do this is I create a field called temp_id by default this
field is NULL. When a user modifies a record you set the original id
into the temp_id and unset the original id:
$this->data['Book']['temp_id'] = $this->data['Book']['id'];
unset($this->data['Book']['id']);
$this->Book->save($this->data);

That creates a new temporary record in the books table where temp_id
refers to the original record.

For the normal index etc I set a
'conditions'=>array('temp_id'=>'null') this way the normal users do
not see the unapproved changes.

The admin view can then use the same model view to see both records
side by side to review what has changed. If the admin approves then
you read from the tempBook record and update the originalBook record
which reverse the changes above and save to the original record. After
the save is done you delete the record with the temp_id.
Load the data as in:
$originalBook = $this->FindByID($id);
$tempBook = $this->FindByTemp_id($id);

In a couple of my models I also have a temp_version which increments
so that I may have multiple changes from the original record. The
admin view becomes a little more complicated but is still a matter of
setting the data using the one model.

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

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


Re: CakePHP 1.2.5 and Mysql 5.0.51a

2010-03-03 Thread LunarDraco
Maybe you should create a cake view, for your debugging purpose.
I do a lot of shell utilities that operate in the same way you
describe where your really only using the controller and modal.
But I still always create a view so I can use and see the debug
information with firebug and firephp.


On Mar 2, 12:58 am, Michiel Rensen  wrote:
> Is there a way in Cake to show debug information *not* in the view but
> in the controller? I'm using cake as a server application with a Flex-
> client over AmfPHP, so I never use cake views, therefor never get to
> see the cake-debug information...
>
> On Mar 1, 5:06 pm, John Andersen  wrote:
>
> > Have you positive proof that it is a CakePHP issue and not a data
> > issue? Have you taken the "offending" SQL statement(s) and executed
> > them in both environments outside of CakePHP?
> > Can you show the SQL code which is the issue?
> > Enjoy,
> >    John
>
> > On Mar 1, 12:11 pm, Michiel Rensen  wrote:
>
> > > Far into the development-process of a project I noticed a discrepancy
> > > in MySQL-database servers between my test-server and the clients test-
> > > server (local test-server -> client's test-server -> clients live-
> > > server). [I know it's a major mistake, but I didn't notice any
> > > problems until now]. They run MySQL 5.0.51a and I run 5.0.67. When I
> > > run a query using the same cake-code on the same data-set results in
> > > different results (there: nothing, here: expected result).
> > > Does anyone know why queries in this configuration (CakePHP 1.2.5 and
> > > MySQL 5.0.51a) result in unexpected results and more importantly does
> > > anyone know a quick fix (i.e. changing server configuration is sadly
> > > but logically not an option)?
>
> > > Thanks in advance!

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

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


Re: falsefalse

2010-03-01 Thread LunarDraco
Which vs of cake are you both using?

Also you may want to read this post which talks a little bit about
containable and hasmany relations. Breaks down when it will work and
when it won't work. Maybe that will give you some ideas about what
might be wrong with your setup or how your making the calls to get the
data your looking for.

http://stackoverflow.com/questions/1497358/containable-on-hasmany-relationship


On Feb 28, 8:40 pm, "Arak Tai'Roth"  wrote:
> Okay, well, I'm still not sure, because everything you did is the same
> as me from what I can tell, except you didn't specify fields grabbed
> in your models. I removed that info in mine, but that didn't change
> anything.
>
> I'm not sure, but I have a feeling this all relates to the fact that
> contain doesn't seem to be grabbing anything that is two levels deep,
> it grabs a model fine and it's associations fine, but it is not
> grabbing the associations of the associations. This seems like a
> recursive problem to me, but I tried setting the recursive property of
> the model and that didn't help, but I might have done it wrong, I
> haven't been able to find an example of doing it.
>
> On Feb 28, 3:29 am, John Andersen  wrote:
>
> > Ok, have recreated your situation - and it just works!
>
> > My result:
> > [result]
> > Array
> > (
> >     [Permit] => Array
> >         (
> >             [id] => 1
> >             [created] => 2010-02-28 10:55:16
> >             [user_id] => 1
> >             [leader_id] => 1
> >             [registration_location_id] => 1
> >         )
> >     [User] => Array
> >         (
> >             [id] => 1
> >             [name] => user1
> >         )
> >     [Leader] => Array
> >         (
> >             [id] => 1
> >             [name] => leader 1
> >             [created] => 2010-02-27 10:53:57
> >             [country_id] => 1
> >             [prov_state_id] => 1
> >             [user_id] => 1
> >             [Country] => Array
> >                 (
> >                     [id] => 1
> >                     [name] => country 1
> >                 )
> >             [ProvState] => Array
> >                 (
> >                     [id] => 1
> >                     [name] => prov state 1
> >                 )
> >         )
> >     [RegistrationLocation] => Array
> >         (
> >             [id] => 1
> >             [name] => location 1
> >         )
> > )
> > [/result]
>
> > based on the Permit controllers find:
> > [code]
> >       $permits = $this->Permit->find(
> >          'first', array(
> >             'conditions' => array(
> >                'Permit.id' => 1
> >             ),
> >             'contain' => array(
> >                'Leader' => array('Country','ProvState'),
> >                'User',
> >                'RegistrationLocation'
> >             )
> >          )
> >       );
> >       debug($permits);
> > [/code]
>
> > Using only the following models:
> > user.php
> > leader.php
> > permit.php
>
> > Thus RegistrationLocation, Country and ProvState uses the AppModel as
> > base.
>
> > My models are defined as:
> > [UserModel]
> > class User extends AppModel {
> >     var $name = 'User';
> >     var $hasMany = array('Leader','Permit');}
>
> > [/UserModel]
>
> > [LeaderModel]
> > class Leader extends AppModel {
> >     var $name = 'Leader';
> >     var $hasMany = array('Permit');
> >     var $belongsTo = array('User','Country','ProvState');}
>
> > [/LeaderModel]
>
> > [PermitModel]
> > class Permit extends AppModel {
> >     var $name = 'Permit';
> >     var $belongsTo = array('User','Leader','RegistrationLocation');}
>
> > [/PermitModel]
>
> > Please compare with your situation, maybe the above will help you on
> > the way.
> > Enjoy,
> >    John
> > On Feb 28, 10:46 am, John Andersen  wrote:
>
> > > Could be! I am trying to recreate your situation here at my place, to
> > > confirm that I too can't retrieve the Country.
> > > Will be back shortly :)
> > >    John
>
> > > On Feb 28, 10:40 am, "Arak Tai'Roth"  wrote:
>
> > > > This is the only thing that is even remotely relevant in app_model:
>
> > > > var $actsAs = array(
> > > >                         'Containable'
> > > >                 );
>
> > > > Other then that, there are only 2 functions, one for validating phone
> > > > numbers, and one for changing dates to a format I want.
>
> > > > Like I have said previously, this is all working when I do the search
> > > > on the model Leader, just not when I do the search on the model Permit
> > > > and have a contain with Leader in it, and then a contain with the
> > > > country data.
>
> > > > So because it works for something, just not quite as deep, I have a
> > > > feeling we are looking in the entirely wrong area.
>
> > > [snip]

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

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To 

Re: Different logic and view for each group

2010-03-01 Thread LunarDraco
Control what is displayed to the end user in your views as mentioned
before. Control user auth and access in the controller via the ACL or
other User auth implementations

You'll also want to make sure your Controllers are very user aware.
Just because the link doesn't show up in the view doesn't mean someone
isn't going to try and visit the link. Especially after seeing the
simple human readable structure of the url /product/28.

Never try to secure your site via the view or by simply hiding the
available actions from the user. The controller should be the place
you verify that the user is authorized to call it.

Even more important is remove the parameter data from the url and add
it to post data when the call is destructive. Like in a delete. don't
request product/delete/28, post product/delete with post data so your
controller can verify $this->data['Product']['id'] and also some other
hashed hidden field which gets changed and verified. Security
Component handles this hash for you and can verify that the field data
provided matches what was given. 
http://book.cakephp.org/view/175/Security-Component

I prematurely deployed a site which was not properly secure and woke
up one morning to an empty database. I know others have posted the
same thing and found that search robots had traversed the site and
stumbled on the many fascinating delete request. Now a day this is the
first thing I take care of when building a new site. Nothing like
learning the hard way to really make the lesson stick ;)

Lunar Darco

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

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


Re: cakephp shell not validating before entering into db?

2010-03-01 Thread LunarDraco
My guess would be that not all the supporting imports are being
loaded. The shell by default does not load much more than is necessary
to run the shell commands. So I've found that most of the time you
need to build up the shell environment to support what you will be
using.
I would try adding this to the top of your shell

App::import('Core', array('Controller','Component',
'View','Model','Router','Validation', 'Behavior'));

Also in my shells I've had to instantiate many of the objects. In
other words the cake magic just doesn't exists. So in my shell's
Initialize I have the following: (this shell deals with a controller a
couple models and a view to send some emails on a cron job.

function initialize() {
//$this->Controller =& new Controller();
//$this->Component =& new Component();
$this->ProfileController =& new ProfilesController();
$this->ProfileController->uses = array('Profile','User');
$this->ProfileController->Profile =& new Profile();
$this->ProfileController->Project =& new Project();
$this->ProfileController->Email =& new EmailComponent();
$this->ProfileController->Email->initialize($this-
>ProfileController);
$this->_loadModels();
}


You could also verify that the Behaviors are loaded by dumping $this-
>Issue->Behaviors or checking to see if it is null. If it is null then
you will not have any validation available.

In the Model class the chunk of code that does the check your
referring to follows the following stack You could add some debug code
to these functions to identify what is different in the environment
between accessing via the web vs the shell.
save(), validation(), invalidFields(), exists()

You might also want to take a look at this page in the manual as the
path environment is also important especially to the imports. Your
shell may not know where to find the right path to import the
behaviors etc.
http://book.cakephp.org/view/846/Running-Shells-as-cronjobs

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

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


Re: How to dynamically create validation rules

2010-03-01 Thread LunarDraco
You could also take a look at this example which shows how to have
different validation based on which action was called for the
controller. So you can have a validation based on the 'add' action
which is completely different from the validation you might use on
'edit' or 'update'. It also shows how to implement custom/dynamic
validation that executes code which means you would be able to do some
other Model lookups to verify against.

I was headed down the same path and have come to realize that most of
what I thought I was going to need custom code validation for was
dealt with nicely by the the different action validations.

This is an article by Jonathan Snook well written and easy to
implement.
http://snook.ca/archives/cakephp/multiple_validation_sets_cakephp/

Lunar Draco

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

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


Re: Answering a recurring challenge from clients

2010-02-23 Thread LunarDraco
@Zaky: I would have to say that I turn away more work than I ever get
to keep in house for the very reasons you mention.
If there is already something that does what the customer needs I
don't want to reproduce it. For instance, I have some very specialized
shopping carts which deal with variable content creation for printing.
These specific carts are NOT built using cake they are built on .NET.
Our sales team is constantly bringing me customers who want to sell
their next great wiget thinking they can just host them on this .Net
store. But they don't qualify to use the .NET variable based shopping
cart for various reasons primarily the cart isn't built for static
items, and as the data for the item is custom to a specific user a
login is required, which just makes generic anonymous cart shopping
difficult. Most of the time I help these customers setup a Yahoo,
Amazon or some other store system. I definitely don't write a custom
cake app. Do I have shopping cart and checkout features? Sure I do,
but the client has to need a lot more than just a cart before I
implement/deploy anything for them.

So of course we evaluate the projects before we take them on. And
there are a number of possible deployments in a number of platforms,
languages, databases, etc. These are often presented to the client as
alternative options and most of the time the better option over
writing a custom app.

However if they have a need, and I have not found a descent solution
that won't cost more than building an app. Then I have some say in
what I am willing to manage for them.

Quite honestly I don't want to write the next great blog system or
shopping cart, etc. I want to solve real business problems for real
business clients.

Most of my cake apps are integration apps to deal with moving data
between systems written by Companies that refuse to talk to each other
or are just to big to care. The advantage of using cake here is I get
a nice web front end to monitor/manage the integration as well as cron
job support from the same code base via console. Sounds like over
kill, and it probably is, I'm sure for most of it I could have used
any number of other platforms or scripting languages. But I'm
efficient in PHP and cake. The clients love being able to view the
info via a browser with built in links that take them to the other
systems.

In other situations, the client doesn't want to have a bunch of
different apps to manage what they do, and after they have a system up
and going, they love the turn around time for new ideas. The best ones
start as an integration between multiple systems. followed by feature
request which eventually replaces one or more of these other systems
and grows into an app that really fits what the company is trying to
accomplish.

I can't remember the last time I sat down to architect design and
build an application from start to finish. It just doesn't happen like
that. So in that sense your right. But the original post was more of a
new client looking to deploy a new CMS. Without all the details I
stand by my original post. With more details I'm sure I would have
started with some other system.

We don't have to agree! And there is nothing quite like a good debate!

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

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


Re: Answering a recurring challenge from clients

2010-02-22 Thread LunarDraco
For my point of view, I want to be designing and building new code to
solve specific client problems. I do not want to be configuring
someone else's already poorly designed and implemented system and
trying to figure out how to solve problems that are created by using
said system.

So I tend to focus on those issues. I usually explain the pit falls of
using a system that is common, popular, etc.
1. You'll have no advantage over your competitors who are using the
same systems.
2. It will be bloated and have many features you don't need or in some
cases don't want and have no way to disable.
3. It will be missing those feature which your business needs that
separates you from your competitors.
4. You'll be stuck using plugins that are written which are close to
what you need but never quite get what your really need.
5. You give up your ability to request a feature and have it
implemented in a timely fashion.
6. You'll be paying to solve problems which have nothing to do with
your business just to make this popular software fit.
7. Integrating your other systems to this popular system will not
always be trivial.

We are a development group, we use solid tools, and languages that are
well known in the development community. We use patterns that are
proven for both stability, and the development time line. We use an
agile weekly cycle. You will have something to start looking at within
a week (it takes less than a day to deploy my shell site). We will
meet regularly, and identify feature priority.

We (my group) already have a bunch of common modules in place with our
starting shell (users, profiles, acl, large file managment, shoping
cart, etc.) these are all highly configurable and very easy for us to
modify as we wrote them and have the source.

My goal is to be able to have a system which can be deployed with
those things that are common to all web sites, and have a high level
of confidence in being able to easily build on top of that core those
client specific needs in as little time as possible. We have a good
base shell and we improve that shell with every site we build on top
of it. This also improves every site we've already deployed.

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

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


Re: Couple of REST questions

2010-02-17 Thread LunarDraco
Check out the manual for Custom REST Routing. You'll want to use
custom instead of Simple as simple sets up routes for edit and delete
which you stat you do not want. So you will need to set a custom route
for each one that you do want to support.
http://book.cakephp.org/view/478/Custom-REST-Routing

Also with your routes set as long as you have your views defined in
the view/xml folder you should get xml, if the view file doesn't exist
in the xml folder I believe the default action is to return the normal
view.
You'll also want to place the RequestHandler as an included component
of your controller which will help in automatically identifying
request type and setting the proper return layout and view type.

var $components = array('RequestHandler');

On Feb 16, 8:49 pm, SonnyBurnette  wrote:
> I just setup a simple example to test REST. I have been able to
> create, edit, delete, etc. How do I ignore REST calls to delete and
> edit but still allow it from the normal web interface?
>
> example: The web interface can go towww.domain.com/users/edit/5but I
> don't want to allow any REST calls there.
>
> Also, I am seeing that I am sending in XML but I am not getting XML
> back when I create records. Shouldn't cakephp know to spit back an XML
> response versus the normal html flash message?

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

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


Re: parent/child navigation best practices

2010-02-16 Thread LunarDraco
I've found over the course of many years, that there are no hard fast
rules to this. There is not one single pattern to follow. Primarily
because the relationships and when you want to see the related
information is based on context. In other words sometimes you want to
see the related information because it has meaning in that context.
Other times the related information is meaningless or even confusing
in other context. Same information same relation different context.

I tend to build view that combine the output of many action/views via
ajax. And present the appropriate information at the right time. I
mostly use the basic actions of index, view, edit. making use of ajax
to place those child view actions inside the parent view container.

The best public view that demonstrates this well is Googles contact
management. Now googles contacts is NOT built on cake, but the design
follows very well the MVC model quite well and is easy to see the
different models and how they relate all on one page.
The main content is a list of contacts on the left and to the right is
a child view which changes depending on the number of contacts
selected. This Child view content changes based on the context of what
is selected in the list. you'll note the contact hasmany emails,
hasmany phones, hasmany addresses, hasmany dates etc. They are
displayed as though they are one record in context of the single
contact that is selected.
If multiple contacts are selected the contact view information is not
displayed as the information is meaningless with multiple contacts
selected. What is displayed is options to do actions on those contacts
that are selected, Delete, Merge, assign to Group etc.
If no contacts are selected the child view contains general help
information about what can be done in contact management.

The child view in my cake version of contact mgt is loaded via ajax
calls to the contact/view/id. The supporting models in this context
are displayed those would be the emails, phones, addresses, etc.

The contact/index only needs to display in the list the Name. However
I still build up portions of the supporting models emails, phones in a
seperate div for popup text when the user hovers over the list item.
If they want further info they can select the contact and it will load
the full view as described above.

Again I think you'll find there is no rule or pattern that covers all
as the relations are only relative in certain context.



On Feb 13, 3:06 am, bberg  wrote:
> hi,
> what would be the best approach when creating a navigation system
> beetwen parent/child relationships?
>
> consider this:
> * Post have many Comment
> * we list all posts at /posts/index
> * we list _all_ comments at /comments/index
> * where do we list comments that belongs _only_ for Post.id=# ?
>
> currently I've been listing them at /posts/view/# or at /comments/
> index/post:#
>
> but both would be no good if I wanted to:
> * show _only_ Post data at /posts/view/#
> * show _all_ Comment at /comments/index (no named params here)
>
> should I have a different method like /comments/parent/# ?
> any ideas?

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

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


Re: Add Fields

2010-01-07 Thread LunarDraco
To solve your problem without irritating the end user I would start
the form with one empty field under your User Defined section with an
"add" button/link to add additional fields to the form. The Add button
should use ajax and client side script to insert additional fields to
the web form.

Next to each additional Field I would place a remove.

With this UI structure you maintain a single form, the UI is not
cluttered with a bunch of empty fields, and your not arbitrarily
limiting any user to a specific number of fields. All the work of
adding/removing fields occurs at the client without the need to do
round trips to the server.

Your model relationship is already setup. However you will need to do
some additional work in the Controller to parse out the data in the
fields and save it to the Many side of your relation.

For a good live example of this type of Web ajax UI take a look at
Googles Contacts in gmail. When you edit a contact you can have
unlimited phone numbers. But it is all done in the one form. Using
ajax to add or remove the additional phone numbers. The underlying
relationship is Contacts have many Phones. They use the same model and
concept for the Contacts Email, Phone, Address and Website.

I really like this UI structure because it solves the very problem
you've presented in a very intuitive way for the end user.


On Jan 6, 1:50 pm, "Dave"  wrote:
> It is a separate Additional table with relations to
> user hasMany Additional,
> Additional belongsTo User
>
> The problem with SCS idea is this is all in 1 form. Does not make sense in
> my situation where a user is editing thier profile in 1 form to send them to
> another form to edit 1 field, and if they have more than 1 additional to go
> thru the repeated process, or fill out half the Profile form to click edit
> additional only to find out any data they changed was not saved and have to
> go back and edit it all over again. Not going to bother saving to data to
> session and all that since this area of the profile is not to important in
> terms of the site.
>
> -Original Message-
> From: cake-php@googlegroups.com [mailto:cake-...@googlegroups.com] On Behalf
>
> Of John Andersen
> Sent: January-06-10 5:09 PM
> To: CakePHP
> Subject: Re: Add Fields
>
> Dave, what is your database design for this issue?
> As scs stated, are you saving the additional information in a separate table
> or in the profile table as 10 independent columns?
> Depending on your answer, we will try better to help you :) In my own
> opinion, scs' idea is sound!
> And if I remember correctly, then CakePHP can accepts more than one record
> for the related table if you use the form field definition as
> Model.indexNumber.fieldname - example: Userinfo.0.uservalue.
> That should also make it easier for you to create the 10 additional
> information form fields by looping!
> Enjoy,
>    John
>
> On Jan 6, 9:45 pm, "Dave"  wrote:
> > Yeah I could do that but the average user will not have more than 3 or
> > 4 and honestly its more of a pain to add new, add new, add new 3 or 4
> > times for the user. This way its all done on 1 page in 1 shot.
>
> > -Original Message-
> > From: cake-php@googlegroups.com [mailto:cake-...@googlegroups.com] On
> > Behalf
>
> > Of scs
> > Sent: January-06-10 4:02 PM
> > To: CakePHP
> > Subject: Re: Add Fields
>
> > The way I would handle this is to add a new table (1->Many) this way
> > you can allow the user to enter as many fields they want.
> > example:
> > CREATE TABLE profile_addons (
> >   id int(10) unsigned NOT NULL auto_increment,
> >   profile_id int(11) unsigned NOT NULL,
> >   name varchar(75) default NULL,
> >   PRIMARY KEY  (`id`)
> > ) ENGINE=InnoDB AUTO_INCREMENT=1 ;
>
> > On Jan 6, 1:34 pm, "Dave"  wrote:
> > > What would be the easiest way to add say 10 input fields to a form
> > > that hasMany?
>
> > > I am allowing a user to add additional info to a profile and want to
> > > have 10 empty fields where they can type in whatever they want.
>
> > > I can manually make a form with 10 input fields but would like to
> > > know a simplified approach.
>
> > > Working with the idea of a foreach and build the fields but cant
> > > seem to get the idea of how to loop thru when there is nothing to loop
> ):
>
> > > $count++
> > > if $count > 10 type idea
>
> > > Ideas to point me in the right direction would be great.
>
> > > Thanks
>
> > > Dave
>
> > No virus found in this incoming message.
> > Checked by AVG -www.avg.com
> > Version: 9.0.725 / Virus Database: 270.14.124/2599 - Release Date:
> > 01/06/10 04:05:00
>
> No virus found in this incoming message.
> Checked by AVG -www.avg.com
> Version: 9.0.725 / Virus Database: 270.14.124/2599 - Release Date: 01/06/10
> 04:05:00
Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-

Re: MySQL takeover by Oracle - petition

2010-01-05 Thread LunarDraco
Isn't it nice to have a descent data layer like we do in cake.
Granted it might be a few days work to switch from MySQL to something
like PostgreSQL for a decent sized project.
But you probably have a few years before we ever get to that point
where we are forced to do so.
Don't sweat the small stuff enjoy the process of change and growth.
I've seen a lot of changes since the 1980's in computer science where
everyone reacted like it was the end of the world. Very few would go
back to work in that environment leaving behind the tools and
technology we have today.

Things change, if they change for the worse thats too bad because
those things occasionally die off.
But I guarantee that those things that don't change and remain
stagnant definitely die.

I really don't think we should have any fear about what the future of
MySQL holds for us. Its new changes that we all have an opportunity to
still contribute to.

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

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


Re: Need help: How can I use xdebug to debug Cake shells?

2009-12-22 Thread LunarDraco
I've always setup my shells to call a Controller Function.
This way I can do all the testing on my shell by calling the
controller function from the browser.

The only thing you put in your shell function is a call to the
Controller function.

Setting things up this way makes it possible to add a controller
function to your cron schedule for background tasks etc.

Setting this up takes a little more work as the Controller will not
have been created yet.

As an example one of my shells is called notify and it sends emails
based on state changes inside a controller. This is scheduled to be
called by the cron system via the shell command once an hour.
Alternately I can call the controller function via a web browser
anytime to force the notification or to see if anythings qualifies for
the state change.

In the shell you need to create and bind your controller and models
the traditional way with php in the shells initialize function. You'll
note in the shell function send() all I do is call the controller
function ProfileController->notify() to do the work. This notify
function is the same function I can call from my browser.
There is a variable that is set in the cake app object I believe which
can indicate weather the call is from the shell. This might be useful
for you in your controller to determine which layout to use.

function initialize() {
//$this->Controller =& new Controller();
//$this->Component =& new Component();
   $this->ProfileController =& new ProfilesController();
$this->ProfileController->uses = array('Profile','User');
$this->ProfileController->Profile =& new Profile();
$this->ProfileController->Project =& new Project();
$this->ProfileController->Email =& new EmailComponent();
$this->ProfileController->Email->initialize($this-
>ProfileController);
$this->_loadModels();
}

function send(){
$this->ProfileController->notify();
}

good luck.

On Dec 22, 8:52 am, Laran Evans  wrote:
> I've read oodles of documentation, I can't find anything anywhere that
> covers how to use xdebug to debug PHP CLI scripts, let alone with
> those written as Cake shells.
>
> This is a huge issue for me right now. Can anyone shed some light on
> this? Thanks.

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

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


Re: validate as hour

2009-11-30 Thread LunarDraco
This regular Expression will force a number between 0-23

Raw Reg ex:
^1?[0-9]{1}$|^2[0-3]{1}$

I'm remembering for php some of these char in the regex provided need
to be escaped.
Formated for PHP:
/^1?[0-9]{1}$|^2[0-3]{1}$/

And here is a good on line real time tester for regular expressions:
http://www.regextester.com/

To break down the regular expression
^ - Start of line
1? - means the number '1' for 0 or 1 occurrences. This is used for the
first char of 10-19
[0-9]{1} - means digits 0,1,2,3,4,5,6,7,8,9 for {1} exactly one
character this covers 0-9 and the second char of 10-19
$ - End of line
| - or condition Match the previous set (0-19) or the following set
(20-23)
^ - Start of line
2 - the number 2 for the first char in 20-23
[0-3]{1} - means digits 0,1,2,3 for {1} exactly one character. This
covers the 0-3 or the second char when the first char is 2
$ - End of line


var $validate = array(
'hour' => array(
'required' => true,
'rule' => '/^1?[0-9]{1}$|^2[0-3]{1}$/',
'message' => 'Only numbers between 0-23'
)
);


On Nov 26, 11:41 am, "ge...@dinnerbooking.com"
 wrote:
> I have an field which is an hour:
>
> "hour" => array(
>         "required" => true,
>         "allowEmpty" => false,
>         "rule" => "/^\d{1,2}+/",
> ),
>
> but how do I also specify that the number MUST be between 0 and 23 ?

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

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


Re: CakeFest IV - America - Help us pick a location!

2009-11-16 Thread LunarDraco
I vote for the West Coast, or even Las Vegas.

--

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




Re: cakephp recursion

2009-10-09 Thread LunarDraco

I've seen this before in a couple of my own projects when you've only
specified that 'Post' in your case is containable.
You may also want to check that all models being used in the contain
statement have defined
var $actAs = ('Containable');

Since all your models seem to use containable you may find it easier
to add this to your appModel class.


On Oct 8, 7:41 pm, broxi  wrote:
> I cant seem to get this to work, here is the code:
>
> $post = $this->Post->find('first', array(
>                                     'conditions' => array(
>                                         'Post.id' => $id
>                                     ),
>                                     'contain' => array(
>                                         'Category',
>                                         'User',
>                                         'Comment' => array(
>                                             'User'
>                                             )
>                                         )
>                                     )
>                         );
>
> it gets all the required info the same as using recursive=1 but doesnt
> get the User data associated with the comments.
>
> any ideas
> Thanks.
>
> On Oct 9, 1:24 am, broxi  wrote:
>
> > Thanks for the reply, I will look into that
>
> > Later
> > Broxi
>
> > On Oct 8, 7:54 pm, Miles J  wrote:
>
> > > Ditch the recursion and use the Containable behavior.
>
> > >http://book.cakephp.org/view/474/Containable
>
> > > On Oct 8, 9:52 am, broxi  wrote:
>
> > > > Hi all,
>
> > > > I am a toatl noob with cakephp, i am trying to build a blog and i feel
> > > > that i am progresing quite well. I just have one question...
>
> > > > I currently have 4 models (post, user, comment, catgeory), when
> > > > reading a post from the database with recursive=0 i only get the
> > > > post,user and category data, using recursive=1 i get the comment info
> > > > too but i also want to get the user info for each comment aswell.
> > > > switching to recursive=2 does this but doubles the query count and
> > > > duplicating some of the queries.
>
> > > > Can you offer any advice on a better, more efficient way to do this.
>
> > > > Thanks for your help
>
> > > > Broxi
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Anyone get the Email Component to work with gmail smtp.gmail.com?

2009-09-04 Thread LunarDraco

You need to make sure in your php.ini you have uncommented the line
extension=php_openssl.dll

Also here is a link that have some samples in php and good comments,
be sure and read them.
Get the simple php test file working first then you should be able to
do it.
http://deepakssn.blogspot.com/2006/06/gmail-php-send-email-using-php-with.html



On Sep 2, 6:53 pm, bunwich  wrote:
> Hi,
>
> I changed the port to 465 and tried 'smtp.gmail.com' for the host.
>
> Also used the host 'ssl://smtp.gmail.com'
>
> The email works fine with sendmail.
>
> Anyone know if tsl/ssl is supported?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Learning cakePHP debugging

2009-09-02 Thread LunarDraco

$activeUser = $this->User->find(array($this->Auth->user('id')));
Not sure I understand why you set the active user with this line:
as $this->Auth->user() should contain everything you need from the
user model.

After a user is logged in you never tell the auth component that the
user has logged out. So even after logging out this->Auth->user
contains a valid user.
I suppose after you've logged out and you click on your login link
from the home page it probably never asks for new credentials and goes
straight to the start page.


At the end of your logout you should be calling:
$this->redirect($this->Auth->logout());

That will clear the $this->Auth->user() object and you can test for it
via:
if($this->Auth->user())

You'll want to set in your beforeFilter:
$this->Auth->logoutRedirect = array('controller' => 'pages', 'action'
=> 'home');

which should take care of your redirect to the home page when a user
logs out.

On Sep 2, 7:54 am, McScreech  wrote:
> @Martin, thanks. debug($activeUser); returns the type of output I was
> expecting.
>
> @abc, I'll look into the php version also.
>
> Now on to my problem, once I actually stopped to _read_ the debug
> output I realized that the $activeUser variable is NOT CHANGING when I
> log out and log back in again. In addition to the partial setup that I
> described above, here are the login and logout functions in my
> users_controller.php:
>
>         function login() {
>                 if( $this->Auth->user() ) {
>                         // Redirect to start page.
>                         $this->redirect( array('controller' => 'pages', 
> 'action' =>
> 'start') );
>                 }
>         } // end login()
>
>         function logout() {
>                 $this->Session->destroy();
>                 $this->Session->SetFlash(__('Successfully logged out', true));
>                 $this->redirect( array('controller' => 'pages', 'action' =>
> 'home') );
>         } // end logout()
>
> I am using php 5.2.9-1 and cakePHP 1.2.3.8166.
>
> Thanx again, McS.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: FreeTDS mssql works from php but not from cakephp

2009-08-26 Thread LunarDraco

Updated! Solved!

I found the problem. I noticed in my php only testconn.php file that I
do not specify the port because connecting to the mssql via FreeTDS is
a mapping connection, the only thing you need to specify is the name
of the map you setup in the /usr/local/etc/freetds.conf file. Mine
looks like:
[wapps01]
host = 192.168.0.92
instance = SQLEXPRESS
port = 1433
client charset = UTF-8
tds version = 8.0

and my connection statement in the testconn.php file looks like:
$link = mssql_connect('wapps01', 'sa', 'casper');

The real host, port, instance etc are defined in the freetds.conf file
very much like a windows ODBC DSN.

After further inspection of the line of code dbo_mssql.php, line 144 I
noticed it was appending the port number 1433 to my server mapping
name.

I corrected the problem by adding the 'port' => '' to my database.php
default config as in:
var $default = array(
'driver' => 'mssql',
'persistent' => false,
'host' => 'wapps01',
'login' => 'sa',
'password' => 'casper',
'database' => 'ChemDry',
'encoding' => 'utf8',
'port' => ''
);

I could have also corrected the problem by adding a definition in my
freetds.conf file of [wapps01:1433]

Thank you for being my sounding board and I hope this helps someone
else in the future.

For further reading on setting up freetds for use with php on unix
accessing an mssql I followed the example given here:
http://docs.moodle.org/en/Installing_MSSQL_for_PHP

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



FreeTDS mssql works from php but not from cakephp

2009-08-26 Thread LunarDraco

I have a microsoft SQL server that I need to connect to.
It has fields that are of type 'Text' which I can not read or write to
with the dbo_mssql.php.

This is a Unix->mssql issue for data type 'Text'

There are a couple of ways to get around this. one is to load FreeTDS
which I have done.
I created a simple php file which uses the built in php mssql
functions mssql_connect, mssql_query, etc. this test file is able to
connect and query and display the data I need.

So I next setup a cakephp project with a db config as:
class DATABASE_CONFIG {

var $default = array(
'driver' => 'mssql',
'persistent' => false,
'host' => 'wapps01',
'login' => 'sa',
'password' => 'password',
'database' => 'mytestdb',
'encoding' => 'utf8'
);
}

When I visit the home page for the cake app to see if it passes all
the default test I get the following error:
Warning (2): mssql_connect() [function.mssql-connect]: Unable to
connect: Adaptive Server is unavailable or does not exist (severity 9)
[CORE/cake/libs/model/datasources/dbo/dbo_mssql.php, line 144]

Has anyone been able to connect to mssql database that uses 'text'
fields?
Has anyone been able to use FreeTDS to connect to mssql from cake.

Looking for some quantity of suggestions or ideas on how I can further
debug this problem and get to a solution.

(I'm really starting to hate microsofts lack of support for non
windows access.)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: 1 Account with Multiple Users?

2009-07-20 Thread LunarDraco

Your verbiage describes clearly what structure you need to create.
I have a very similar structure with a few of my sites, because I
support more than one authentication via  www.rpxnow.com which is a
service to support OpenID so my users can associate their account with
multiple login services (Google, Yahoo, Facebook) this enables them to
use an already existing UserName and Password which they don't have to
share with anyone. My site uses these other sites to authenticate I
get a token back which confirms the association and I grant them
access.

Your request really has nothing to do with Authentication. The
authentication role is still the same weather its the Primary User or
a Secondary User.
You should create a structure like this:
Accounts have many Users
Users has a Profile
Users belong to Accounts
Users have and belong to Groups (or Users belong to Groups) I like to
set this one up as a many to many relation.
Accounts have and belong to Groups

Mine is simular, however I have Company instead of Accounts as in
Companies have many Users
Users has a Profile
Users belong to Companies
Users have and belong to Groups
Companies have and belong to Groups

Then using the auth component each user can be authenticated as
normal.
Using ACL, ACOand ARO you can assign rules for specific members or
spacific Groups to be super users for that specific company with
rights to manage the users for that Company.
Also each Account or Company could then be assigned its own set of
access rules.

So really I do believe you get what your looking for out of the box,
once you get your models setup correctly and make use of both the Auth
components and the ACL components you should be well on your way.

On Jul 18, 7:31 pm, thatsgreat2345  wrote:
> Yeah this isn't exactly a normal request, but you could somehow set up
> a that a User has a field inside itself that is user_id. So when their
> is a primary account it sets the field to 0, however when their is a
> secondary account it sets user_id to a parent account. So when Auth
> component tries to login it will only have to look in the users table,
> however you'll have to do some programming to sort out if there is a
> parent account or this is a secondary account.
>
> On Jul 18, 1:50 pm, mindpike  wrote:
>
> > Is the built in auth mechanisms in CakePHP able to handle a single
> > account that has multiple logins? I.E. Login Primary logs in on his
> > dashboard clicks add user adds user Secondary. User secondary logs in
> > with his user name and password but it is simply an alternative login
> > for the Primary sharing the same account?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Created & modified fields automatically populating in models

2009-03-25 Thread LunarDraco

You also might want to make sure your tmp/cache/models is flushed out.
If you had originally setup the user table without the created and
modified fields the schema of the model would have been cached that
way. If they were cached cake will use the cached version of the
schema and may not be seeing the created and modified fields.

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



Re: Created & modified fields automatically populating in models

2009-03-25 Thread LunarDraco

Whats in your User modal class? Do you have a before save or does the
class use any behaviors?

On Mar 25, 2:25 am, Turgs  wrote:
> I've tried switching to InnoDB and that hasn't worked either.
>
> There versions of what I'm using are:
>
> CakePHP 1.2.2.8120
> PHP 5.2.6
> MySQL 5.0.41
>
> Thanks for your interest in helping me out.
> Turgs
>
> Miles J wrote:
> > Your tables should be InnoDB FYI, try switching them.
> mscdex wrote:
> > Out of curiousity, what version of CakePHP and MySQL are you using?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Performance different between cakephp 1.1 and 1.2

2009-03-19 Thread LunarDraco

Add a log  statement to your AppController.beforeFilter()

function beforeFilter(){
  FireCake::log($this->name,$this->action);
}

I've had several occasions while integrating Auth and other components
where I've created a situation where a single controller was being
called in a loop fashion because I provided the wrong controller
action to the component etc.

This statement will show you a stack trace of your requestActions.


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



Re: Cake performance tips

2009-03-06 Thread LunarDraco

I would start a simple test with two different database.
one very small with at least one but no more than 5 records per table.

Then do another test with a database with at least 1000 records in the
tables that you would expect to grow.
If your code is setup correctly with view pagination etc. the time
between these two scenarios should change very little.

If you see a huge delay difference with the 1000 record database, then
you definitely have some bind or containable work to do.

If both scenarios are slow, your going to have to look a little deeper
at your code. As an example I had a wicked loop in my Auth and Menu
system which generated 250+ querys for something that should have only
been 13. Add to that a lazy find on my groups table which was bound to
my Users via a HABTM mapping netting more than a few thousand users
being pulled in for every cycle in this loop.

I guess my point is cake is very flexible. Flexible enough to let you
dig yourself a pretty deep hole. The DebugKit and FireCake has proven
to be a priceless set of tools for debugging (mainly because their
free) and they are very will put together, great examples of how to
write plugins. I would add a couple log statments in your
app_controller beforeFilter. spit out the controller and action that
is being called. This will show you a nice trace of what your app is
doing. I find this a good practice to run every once in a while. If
you want a real test write down on paper what you think the trace of
your app should look like for say logging in. Then log in and compare
I'm going to bet there some stuff happening that you wouldn't expect.


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



Re: RPXnow OpenID

2009-02-27 Thread LunarDraco

> > CakeBaker: any chance you've got plans to update your Component?
>
> No, there are no plans to integrate support for RPX into the OpenID
> component, because support for a proprietary API doesn't fit to the
> current functionality of the OpenID component. I think it is better to
> put the RPX functionality into its own component.

After I sent the message to the group I implemented RPXnow last night
and I agree with you completely in this doesn't belong or fit well
with your component.
Actually I'm not sure it even requires its own component. There is so
very little code to make it work and to integrate it into your
existing users I think a clean example would be more useful.

Now I can authenticate via the legacy Cake Auth, I can authenticate
via the OpenID Component (Great component by the way) and I can
authenticate via RPXnow.
I think the problem with OpenID is its still a little immature and if
I provide enough UI to help those who don't understand what an OpenID
URL is, my login page starts to look like a bunch of random sponsor
links.

However I'll take that over the 100's of username/passwords I have for
all those sites visit. ;)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



RPXnow OpenID

2009-02-26 Thread LunarDraco

Has anybody started work on a plugin for https://rpxnow.com/ which is
the replacement for idselector to help assist non geek users in
logging in using OpenID?
I really like the idea and concepts behind OpenID. The problem seems
to be that users don't realize they have an OpenID and even when they
finally realize they already have one knowing what the url for their
openid service isn't very intuitive.
https://rpxnow.com/ helps solve some of that problem of knowing what
the url is by making it visual and provides a nice UI and remember me
feature for one click pass through after initial validation.
Plus it offers Profile Info sharing so the user doesn't have to retype
all the same profile fields in every site.
CakeBaker: any chance you've got plans to update your Component?

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



Re: Problem with email component after upgrade to 1.2 final

2009-02-18 Thread LunarDraco

> If you use 1.2.1 stable it should work as expected without any extra
> calls.

For me, I'm using the email component from the console shell. The
console shell doesn't load up hardly anything automagically, so in my
case it is required to make the call.
This shell is then in turn called by a cron job to periodically check
our ftp site for updated files and send out notifications. The logic
for this check is done within a controller. So my shell loads the
controller, then creates and loads the email component. Associates the
email component and controller and then I call my action in the
controller.


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



Re: Problem with email component after upgrade to 1.2 final

2009-02-17 Thread LunarDraco

I ran into the same problem. The change that was made was in version
7969
The startup function mention by brian was replaced in the email.php
with initialize so that it could be used easier by other components.

My code that used this and got the same error used to look like:
$this->ProfileController =& new ProfilesController();
$this->ProfileController->Email =& new EmailComponent(null);
$this->ProfileController->Email->startup($this->ProfileController);

I had to change the last line to:
$this->ProfileController->Email->initialize($this-
>ProfileController);

And everything worked fine for me after that change.
So Brenda in your SendEmail function of you custom component you may
need to call something like this:
$this->Email->initialize($this);

The initialize function takes a second parameter for settings as an
array that I'm not using but it may help minimize the amount of calls
to $this->Email->property = value; calls.

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



Re: Separating user and profile tables

2009-02-16 Thread LunarDraco

I use EAV because I have multiple clients using the same user/profile
code. Each client wants a different list of profile fields. I found
myself rewritting the same code slightly different each time. It was
time to automate some of that process.
I have two models Profile and ProfileFields. The ProfileFileds has its
own set of admin actions, Model, controller and view set for adding,
updating the ProfileFields.

In the Profile model itself I have a few fixed fields which are
available for everyone "First Name","Last Name", "email" and also my
foreign key to bind to the user.

> Actually, I can't see how using EAV would mean that updating
> view/models would be unnecessary. If they don't change, what's the
> point in adding new attributes?

The view of the Profile is generated from the data in the
ProfileFileds so It is not being modified manually there is some logic
behind this that generates the display elements. Pretty much like how
cake bakes in the first place. This one just bakes on the fly based on
the available ProfileFileds. Each ProfileFileds recorde has a Group
Level for when the field should be visible so each users gets a
different set of profile fields based on which group(s) they belong
to.

The goal of dynamicly adding a new profile field presents a problem
with existing users of getting them to fill in the new field.
This is solved by checking if the profile for a user is valid when
they login. If it is not valid redirect to the proifle edit. Now when
I add a new field the next time a user logs in he is redirected to
fill in the new field for his profile.
if(!$this->Profile->validates()){
  $this->Session->setFlash(__('Your profile is out of date or missing
new required fields. Please update your profile.',true));
  $this->redirect(array('admin' => false, 'controller' =>
'profiles','action'=>'edit', $this->data['Profile']['id']));
}

I've started to convert this user/profile code to a cake plugin
because the power of cake Plugins make it possible for this User/
Profile plugin to be deployed into any of the apps I create. My apps
are primarily intended to be deployed/run within my client companies
LAN, because the data is somewhat sensitive to that client company.

I agree if this were a single site with a single app the EAV pattern
does not make sense. But my goals are to broaden my client base and
reduce my time to deploy for those clients. User Authentication and
Profile info is almost always a required part of the app and almost
always has a different set of fields. Cake's plugins have really
helped with that goal. And a configurable plugin minimizes the number
of different User profile MVC logic I need to build. I will have one
configurable plugin to maintain for many different sites.

Remember these development design patterns exist for a reason, that
reason is to solve a specific problem. It may not always be clear up
front why the pattern was used when thinking or looking at a single
app. Clearly if the EAV is not solving a problem for you then you
should not be using it. Perhaps your app or goal has different
requirements and the problem you are trying to solve does not benefit
from the EAV pattern.

I intend to make public my User/Profile plugin once it is fully
refined and I have the time to properly write a clean article
explaining all the the objects and what they do. A lot of this code
has come from many different post's and ideas generated in these
forums its only right that I share back to the community. The first
release of this plugin will use Auth but does not use ACL. However I
know ACL is an important piece of the puzzle for some apps, I'm just
waiting for it to mature, or rather I'm waiting for my brain to mature
enough to completely understand cake's implementation of ACL.

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



  1   2   >