Monday, April 30, 2012

Need help in Ajax

<p id="post3">
</p>
<p>
<?php echo $ajax->link(
'Response will be add at the top of selected element',
array( 'controller' => 'ajax', 'action' => 'view', 3 ),
array( 'update' => 'post3', 'position' => 'prepend')
);
?>
</p>


Where to use this and it shows error like

Undefined variable: ajax [APP\View\Posts\index.ctp, line 39]

--
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: cakePHP 2.1, ckeditor + ckfinder

this is my sample code for wotk with ckeditor

1.copy ckeditor in "webroot/js"

2. in view :

<?php echo $this->Html->script('ckeditor/ckeditor'); ?>


<?php
        echo $this->Form->textarea('info',array('class'=>'ckeditor','id'=>'editor_office2003'));
    ?>
    </fieldset>

--
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

cookie and array

hi
 i want send array to some cookie and then i want push some values to this array in cookie.
for example:
in cookie i have this:
array()
then
array([0]=>1)
then
array([0]=>1,[1]=>2)
then
array([0]=>1,[1]=>2...)

this is my code:

        $arr=$this->Cookie->read('braceletid');
                array_push($arr,$id);
        $this->Cookie->write('braceletid', $arr);

        pr($this->Cookie->read('braceletid'));

i want use this array like this.

example:

if (in_array(1,cookie array){
echo 'yes';
}

--
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: cakePHP 2.1, ckeditor + ckfinder

1. Check the folder is present at the correct location.
2. Please check the folder permissions are correct.
3. The folder needs 777 permissions for uploading a file.
4. set

function CheckAuthentication()
{
// WARNING : DO NOT simply return "true". By doing so, you are
allowing
// "anyone" to upload and list the files in your server. You must
implement
// some kind of session validation here. Even something very simple
as...

// return isset($_SESSION['IsAuthorized']) &&
$_SESSION['IsAuthorized'];

// ... where $_SESSION['IsAuthorized'] is set to "true" as soon as
the
// user logs in your system. To be able to use session variables
don't
// forget to add session_start() at the top of this file.

return true;
}

Hope this will help.

On May 1, 8:25 am, Sean <sean.rac...@gmail.com> wrote:
> For those that are having this problem as well, here is what I was able to
> do. This took a lot of trial and error on my part!
>
> I have mine in:
>
> app/webroot/js/ckeditor
> app/webroot/js/ckfinder
>
> I don't have anything special in my ckeditor config, just the default.
>
> For ckfinder, here is my config:
>
> * Put these lines at the top of the file after the <?php :
>      * session_name('YOUR SESSION NAME'); - I found that my session name
> was NOT 'CAKEPHP' but what I have the cookie named.
>      * session_start();
>
> * In CheckAuthentication I have:
>      *  if (!empty($_SESSION["Auth"])) {
> if(!empty($_SESSION['Auth']['User']['admin'])) {
> return true;}
> }
>
> return false;
>      * The only place that I use ckeditor and ckfinder is in my admin area,
> so I not only check
>        for user logged in, but also for admin privileges as well.
> (Although, if it's configured properly
>        non admin users shouldn't be able to reach that point anyway, just
> for added security.)
>
> For the $baseURL:
>      * $baseURL = '/path_to_cake_app/app/webroot/img/files/' - trailing
> slash required!!!
>        (eg. '/test_dir/app/webroot/img/files/'
>      * For the default ckfinder directory:
> '/path_to_cake_app/app/webroot/js/ckfinder/userfiles/'
>      * I haven't tried this on my live host yet, but I would think that
> simply removing the leading path to the app
>        would work in a production environment ('/app/webroot/...'), I
> should know shortly as I expect to turn this
>        into production very soon.
>
> For the $baseDir:
>      * $baseDir = resolveUrl($baseUrl); - this is the default configuration
> and works well.
>
> For the view:
>      *  <?php echo $this->Form->input('body', array('id' => 'body', 'class'
> => 'ckeditor', 'label' => false)); ?>
> <script type="text/javascript">
> var CustomHTML = CKEDITOR.replace( 'body',
> {filebrowserBrowseUrl :
> '/path_to_cake/app/webroot/js/ckfinder/ckfinder.html',filebrowserWindowWidth
> : '1000',filebrowserWindowHeight : '700'}
> );
> </script>
>
> What I haven't quite figured out is how to turn the label off on the
> replaced editor. I have CSS that puts an asterisk (*) after required fields
> and it appears at the very bottom right after the editor window. Anyone
> have any ideas on how to remove the label from that? I assume it's being
> treated as a form field of it's own. I'm not as familiar with JS as I am
> PHP and CakePHP.
>
> Any help with that little issue would be appreciated.
>
> Elsewise, I hope this helps.
>
> Sean
>
>
>
>
>
>
>
> On Friday, April 27, 2012 2:21:45 PM UTC-4, Sean wrote:
>
> > Hello again,
>
> > I am working with cakePHP 2.1.0 and have incorporated ckeditor and
> > ckfinder. I have gotten the editor window to come up and even gotten the
> > ckfinder "Browse Server" button to work. What I am having problems with now
> > is that when I hit the "Browse Server" button, the window opens, but gives
> > me the dreaded "Folder not found. Please refresh and try again." error.
>
> > I have Googled, and RTFM, but to no avail. I'm not sure what else to do. I
> > have tried using my own file structure, and using the default.
>
> > Here is some code:
>
> > /*
> > To make it easy to configure CKFinder, the $baseUrl and $baseDir can be
> > used.
> > Those are helper variables used later in this config file.
> > */
>
> > /*
> > $baseUrl : the base path used to build the final URL for the resources
> > handled
> > in CKFinder. If empty, the default value (/userfiles/) is used.
>
> > Examples:
> > $baseUrl = 'http://example.com/ckfinder/files/';
> > $baseUrl = '/userfiles/';
>
> > ATTENTION: The trailing slash is required.
> > */
> > $baseUrl = '/js/ckfinder/userfiles/';
>
> > /*
> > $baseDir : the path to the local directory (in the server) which points to
> > the
> > above $baseUrl URL. This is the path used by CKFinder to handle the files
> > in
> > the server. Full write permissions must be granted to this directory.
>
> > Examples:
> > // You may point it to a directory directly:
> > $baseDir = '/home/login/public_html/ckfinder/files/';
> > $baseDir = 'C:/SiteDir/CKFinder/userfiles/';
>
> > // Or you may let CKFinder discover the path, based on $baseUrl.
> > // WARNING: resolveUrl() *will not work* if $baseUrl does not start with a
> > slash ("/"),
> > // for example if $baseDir is set to  http://example.com/ckfinder/files/
> > $baseDir = resolveUrl($baseUrl);
>
> > ATTENTION: The trailing slash is required.
> > */
> > $baseDir = resolveUrl($baseUrl);
>
> > At the moment, I have authentication turned off. I don't think it will
> > matter as this is in the admin area which has NO public access. Only myself
> > and another admin.
> > I have tried to use authentication and couldn't get that working either.
>
> > I just don't know what these settings should be. I really like cakePHP,
> > but getting ckfinder has been REALLY mind-blowing.
> > I made this conversion b/c my old FCKeditor didn't work when I ported over
> > from 1.2
>
> > Any help would be appreciated.
>
> > Thanks

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


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

Re: cakePHP 2.1, ckeditor + ckfinder


For those that are having this problem as well, here is what I was able to do. This took a lot of trial and error on my part!

I have mine in:

app/webroot/js/ckeditor
app/webroot/js/ckfinder

I don't have anything special in my ckeditor config, just the default.

For ckfinder, here is my config:

* Put these lines at the top of the file after the <?php :
     * session_name('YOUR SESSION NAME'); - I found that my session name was NOT 'CAKEPHP' but what I have the cookie named.
     * session_start();

* In CheckAuthentication I have:
     *  if (!empty($_SESSION["Auth"])) { 
if(!empty($_SESSION['Auth']['User']['admin'])) {
return true; 
}
return false;
     * The only place that I use ckeditor and ckfinder is in my admin area, so I not only check
       for user logged in, but also for admin privileges as well. (Although, if it's configured properly
       non admin users shouldn't be able to reach that point anyway, just for added security.)

For the $baseURL:
     * $baseURL = '/path_to_cake_app/app/webroot/img/files/' - trailing slash required!!!
       (eg. '/test_dir/app/webroot/img/files/'
     * For the default ckfinder directory: '/path_to_cake_app/app/webroot/js/ckfinder/userfiles/'
     * I haven't tried this on my live host yet, but I would think that simply removing the leading path to the app
       would work in a production environment ('/app/webroot/...'), I should know shortly as I expect to turn this
       into production very soon.

For the $baseDir:
     * $baseDir = resolveUrl($baseUrl); - this is the default configuration and works well.

For the view:
     *  <?php echo $this->Form->input('body', array('id' => 'body', 'class' => 'ckeditor', 'label' => false)); ?>
<script type="text/javascript">
var CustomHTML = CKEDITOR.replace( 'body',
{filebrowserBrowseUrl : '/path_to_cake/app/webroot/js/ckfinder/ckfinder.html',filebrowserWindowWidth : '1000',filebrowserWindowHeight : '700'}
);
</script>

What I haven't quite figured out is how to turn the label off on the replaced editor. I have CSS that puts an asterisk (*) after required fields and it appears at the very bottom right after the editor window. Anyone have any ideas on how to remove the label from that? I assume it's being treated as a form field of it's own. I'm not as familiar with JS as I am PHP and CakePHP.

Any help with that little issue would be appreciated.

Elsewise, I hope this helps.

Sean

On Friday, April 27, 2012 2:21:45 PM UTC-4, Sean wrote:
Hello again,

I am working with cakePHP 2.1.0 and have incorporated ckeditor and ckfinder. I have gotten the editor window to come up and even gotten the ckfinder "Browse Server" button to work. What I am having problems with now is that when I hit the "Browse Server" button, the window opens, but gives me the dreaded "Folder not found. Please refresh and try again." error.

I have Googled, and RTFM, but to no avail. I'm not sure what else to do. I have tried using my own file structure, and using the default.

Here is some code:

/*
To make it easy to configure CKFinder, the $baseUrl and $baseDir can be used.
Those are helper variables used later in this config file.
*/

/*
$baseUrl : the base path used to build the final URL for the resources handled
in CKFinder. If empty, the default value (/userfiles/) is used.

Examples:
$baseUrl = '/userfiles/';

ATTENTION: The trailing slash is required.
*/
$baseUrl = '/js/ckfinder/userfiles/';

/*
$baseDir : the path to the local directory (in the server) which points to the
above $baseUrl URL. This is the path used by CKFinder to handle the files in
the server. Full write permissions must be granted to this directory.

Examples:
// You may point it to a directory directly:
$baseDir = '/home/login/public_html/ckfinder/files/';
$baseDir = 'C:/SiteDir/CKFinder/userfiles/';

// Or you may let CKFinder discover the path, based on $baseUrl.
// WARNING: resolveUrl() *will not work* if $baseUrl does not start with a slash ("/"),
// for example if $baseDir is set to  http://example.com/ckfinder/files/
$baseDir = resolveUrl($baseUrl);

ATTENTION: The trailing slash is required.
*/
$baseDir = resolveUrl($baseUrl);

At the moment, I have authentication turned off. I don't think it will matter as this is in the admin area which has NO public access. Only myself and another admin. 
I have tried to use authentication and couldn't get that working either.

I just don't know what these settings should be. I really like cakePHP, but getting ckfinder has been REALLY mind-blowing. 
I made this conversion b/c my old FCKeditor didn't work when I ported over from 1.2

Any help would be appreciated.

Thanks

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

Re: CakePHP (2.1) Media Plugin - Multi File Upload

Hi Jeremy,

Not having much luck with the saving manually option, do you having
any working examples of drag and drop (jquery) I can look at?

Thanks,

-Brett

On Apr 17, 7:44 am, jeremyharris <funeralm...@gmail.com> wrote:
>
> Or, instead of using the multiple option, you can try processing them each
> as a single request so you don't have to change anything in your controller
> but rather just how the view presents it. I've used drag and drop jQuery
> plugins and the like to help with this. It's by far my favorite solution,
> because it doesn't rely on browser specific features (such as HTML5
> multiple upload).
>

--
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: Cakephp SSN Encryption

#1 http://bakery.cakephp.org/articles/jmillerdesign/2011/12/29/cipher_plugin_behavior
#2 http://www.pentaho.com/download/



On Mon, Apr 30, 2012 at 4:46 PM, Steven Scaffidi <sscaff1@gmail.com> wrote:
Hi - I'm looking for information on how to encrypt data in Cakephp. My
employer had a client management system built in Microsoft Access, and
I recently took that application and put it on a web-based space built
in cake. I need to now two things:

#1 How can I encrypt social security numbers from new clients coming
into the system? I'm encrypting passwords right now, but I'm not sure
how to do social security numbers.

#2 How do I take social security numbers that are currently listed in
Microsoft Access with no encryption and put them into the MySQL
database encrypted?

Thanks for the help,

Steven

--
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

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

Cakephp SSN Encryption

Hi - I'm looking for information on how to encrypt data in Cakephp. My
employer had a client management system built in Microsoft Access, and
I recently took that application and put it on a web-based space built
in cake. I need to now two things:

#1 How can I encrypt social security numbers from new clients coming
into the system? I'm encrypting passwords right now, but I'm not sure
how to do social security numbers.

#2 How do I take social security numbers that are currently listed in
Microsoft Access with no encryption and put them into the MySQL
database encrypted?

Thanks for the help,

Steven

--
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: Google Map interface question

This won't be exactly what you're after, but I have recently implemented something quite similar. The following (1.3 code) will allow the user to drag and drop a pin to change the lat/long of that pin on the fly.

View

The first thing you'll need is to do is add a couple of json properties when you're defining each of your markers in your view, for example:

var marker = new google.maps.Marker({
...
                callbackUrl: "http://www.yoursite.com/<controller>/<action>/<id>",
                draggable: true
});

Then you'll need to add an event listener to listen for the "dragend" event of the pin:

// Add a "dragend" event listener so that we can determine the lat/long of the drop point
google.maps.event.addListener(marker, "dragend", function() {

var position = marker.getPosition();
var _data = "latitude=" + position.lat() + "&longitude=" + position.lng();
$.ajax({
type: "POST",
url: marker.callbackUrl,
data: _data,
success: function(data) {
// Do some stuff to notify the user that the lat/long has been updated
}
});

});

Controller

In your callback action within your controller, you'll need something like this:

function <action>($id = null) {
$this->autoRender = false;

if ($this->RequestHandler->isAjax()) {

Configure::write('debug', 0);
$this->layout = 'ajax';

$data['<Model>']['id'] = $id;

// Build up the data based on the posted form values
foreach($this->params['form'] as $key => $value) {
$data['<Model>'][$key] = $value;
}
// Save the data
if (!$this-><Model>->save($data)) {
$this->log($data, 'error');
$this->log($this-><Model>->validationErrors, 'error');

$this->set('message', 'There was an error updating the location for <b>' . $<model>['<Model>']['name'] . '</b>');
$this->render('/elements/flash/error', 'ajax');
} else {
$this->set('message', 'The location for <b>' . $<model>['<Model>']['name'] . '</b> has been updated');
$this->render('/elements/flash/success', 'ajax');
}
}
}

Like I said, I know this isn't exactly what you're after, but hopefully it will be of some use to you.

On 30 Apr 2012, at 05:13, Michael Gaiser wrote:

So, I want to use Google maps on my project which makes use of a
Location model. In that model there is a longitude and latitude value.
Most of the tutorials I have looked at talk about how to place
markers on your map. What I want to do is use the map to allow people
to navigate to the location they are editing and set the longitude and
latitude based on the current center of the map giving an easy
interface for entering in such values. So it leads me to this
question: How do I get the long/lat values from the google map and
save those values to my database? Thanks.

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


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

Re: Problems in making a page with "yes", "no" buttons and confirm dialog

Thanks for the advice.

--
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: Problems in making a page with "yes", "no" buttons and confirm dialog

On Mon, Apr 30, 2012 at 2:01 PM, Daniel <danwgrace@gmail.com> wrote:
> 1. the confirm dialog / message appears when the "no" button is
> clicked.

Because both of the buttons are submit buttons. The confirm is called
on onsubmit().

> 2. the check on params['form']['no'] does not seem to stop the delete
> when "no" is clicked.

Perhaps you're making assumptions about the format of the data.

die(debug($this->params));

> 3. the "no" button appears underneath the "yes" button, instead of to
> the right of it.

This is a CSS problem.

I think you should take a step back and re-evaluate what it is you're
trying to do here. Ask yourself if it makes any sense to have "yes"
and "no" submit buttons in the first place. Why would anyone click the
"no" button? You already have a javascript confirm check. Change 'Yes'
to 'delete" or something like that, remove the 'No' button, as well as
the test in the controller, and you'll be on your way.

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


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

Re: Soft Delete

I did. It works. I have another problem that is related to my DB.

Thanks for the help though.

Regards,

Will

"What's wealth but the means of expanding once  life? There's two ways one can do it: either by producing more our by producing it faster. And that is what I'm doing. I'm manufacturing time." Ellis Wyatt from Atlas Shrugged

Sent from VeryBerry-White Book Device

On Apr 30, 2012 2:38 PM, "lowpass" <zijn.digital@gmail.com> wrote:

ife() was removed in 2.x. Just change the code to use ternary, eg.
$foo ? $foo : $bar;


On Mon, Apr 30, 2012 at 12:41 AM, Will <will.a.salazar@gmail.com> wrote:
> Trying to do a Soft Dele...

--
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: Soft Delete

ife() was removed in 2.x. Just change the code to use ternary, eg.
$foo ? $foo : $bar;

On Mon, Apr 30, 2012 at 12:41 AM, Will <will.a.salazar@gmail.com> wrote:
> Trying to do a Soft Delete in CakePHP. I initially googled it and got some
> hits. The first hit was for a SoftDeletable class. I followed all of the
> instructions, however, there is an error in the code, which I do not know
> how to fix since I didn't write it. I could probably email the author but I
> was wondering if any of you here has dealt with this issue.
>
> http://cake-syrup.svn.sourceforge.net/viewvc/cake-syrup/trunk/app/models/behaviors/soft_deletable.php?view=markup
>
> This is the link in which I got the SoftDeleteBehavior class from, However,
> when I refresh my browser I have an error on line 45 that has to do with the
> ife() function.
>
> Can anyone help? Thanks.
>
> --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> cake-php+unsubscribe@googlegroups.com For more options, visit this group at
> http://groups.google.com/group/cake-php

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


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

Problems in making a page with "yes", "no" buttons and confirm dialog

I am trying to make a delete confirmation page with both "yes" and
"no" buttons, and a confirmation dialog box. The dialog is to confirm
the "yes" option. Here is the relevant code I have:
(in the ctp view file)
<?php echo $this->Form->create('User', array(
'onsubmit' => 'return confirm("Really delete this account?");')); ?>
...

<?php echo $this->Form->submit(__('Yes')); ?>
<?php echo $this->Form->submit(__('No'), array('name' => 'no')); ?>
<?php echo $this->Form->end();?>

(in the controller)
public function delete($id = null) {
if (isset($this->params['form']['no']))
$this->redirect(array('action' => 'index'));
else {
$this->User->id = $id;
if (!$this->User->exists())
throw new NotFoundException(__('Invalid user'));
$user = $this->User->Find('first', array('conditions' =>
array('User.id' => $id)));
$this->set('user', $user);
if ($this->request->is('post') || $this->request->is('put')) {
if ($this->User->delete()) {
$this->Session->setFlash(__('User deleted'));
$this->redirect(array('action' => 'index'));
}
$this->Session->setFlash(__('User was not deleted'));
$this->redirect(array('action' => 'index'));
}
else
$this->request->data = $this->User->read(null, $id);
}
}

The problems are as follows:
1. the confirm dialog / message appears when the "no" button is
clicked.
2. the check on params['form']['no'] does not seem to stop the delete
when "no" is clicked.
3. the "no" button appears underneath the "yes" button, instead of to
the right of it.

Thanks.

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


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

Re: paginator with user defined page sizes...

Still can't get this to 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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: Paginating cached data



On Monday, 30 April 2012 06:02:55 UTC+2, Jeremy Burns wrote:
It's a 1.3 app, unfortunately. I've almost cracked it and will post back here - hopefully later today.

The datasources repo is 2.x and 1.3

AD

--
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: problem

does folder "cakephp" in your webroot exists ??

if u use xampp for linux, then default webroot is "htdocs" folder inside xampp, check there..

--
Lep pozdrav, Tilen Majerle



2012/4/30 darryl bautista <darrylbautista.93@gmail.com>
hi, i have a problem with my apache2, when i type to my browser the localhost/cakephp/ this text appear

Not Found

The requested URL /cakephp was not found on this server.


Apache/2.2.20 (Ubuntu) Server at localhost Port 80


can you please help me? thanks

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

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

Sunday, April 29, 2012

modelling two different table

I have Visit and Consult table both are related through table Patient.
i.e The visit and Consult table have foreign key patient_id. I have to
edit this two tables (Visit and Consult) on a single edit action.i.e
in edit view both tables data should display.
What model I have to use?
Thanks.........

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


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

Re: Google Map interface question

You could use something like 
So this could populates the lat/lng values to a form input field and you can save that…

they have sample code:

Andras Kende




On Apr 29, 2012, at 10:33 PM, Daniel Baird wrote:


To get the long and lat, you have to use javascript, and the Google Maps API -- so you mightn't get much help on that from this CakePHP list.

Once your javascript has the values in the user's browser, you'll need to post them back to  your cake app somehow; probably just dumping the numbers into form fields for the user to submit would be fine.

From memory Google have a web service for getting the longitude and latitude for a street address; have you thought about using that?

Cheers
Daniel

On Mon, Apr 30, 2012 at 2:13 PM, Michael Gaiser <mjgaiser@gmail.com> wrote:
So, I want to use Google maps on my project which makes use of a
Location model. In that model there is a longitude and latitude value.
 Most of the tutorials I have looked at talk about how to place
markers on your map. What I want to do is use the map to allow people
to navigate to the location they are editing and set the longitude and
latitude based on the current center of the map giving an easy
interface for entering in such values. So it leads me to this
question: How do I get the long/lat values from the google map and
save those values to my database? Thanks.

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


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



--
Daniel Baird
I've tried going to the XHTML <bar /> a few times, but it's always closed.


--
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: Google Map interface question


To get the long and lat, you have to use javascript, and the Google Maps API -- so you mightn't get much help on that from this CakePHP list.

Once your javascript has the values in the user's browser, you'll need to post them back to  your cake app somehow; probably just dumping the numbers into form fields for the user to submit would be fine.

From memory Google have a web service for getting the longitude and latitude for a street address; have you thought about using that?

Cheers
Daniel

On Mon, Apr 30, 2012 at 2:13 PM, Michael Gaiser <mjgaiser@gmail.com> wrote:
So, I want to use Google maps on my project which makes use of a
Location model. In that model there is a longitude and latitude value.
 Most of the tutorials I have looked at talk about how to place
markers on your map. What I want to do is use the map to allow people
to navigate to the location they are editing and set the longitude and
latitude based on the current center of the map giving an easy
interface for entering in such values. So it leads me to this
question: How do I get the long/lat values from the google map and
save those values to my database? Thanks.

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


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



--
Daniel Baird
I've tried going to the XHTML <bar /> a few times, but it's always closed.

--
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Soft Delete

Trying to do a Soft Delete in CakePHP. I initially googled it and got some hits. The first hit was for a SoftDeletable class. I followed all of the instructions, however, there is an error in the code, which I do not know how to fix since I didn't write it. I could probably email the author but I was wondering if any of you here has dealt with this issue.

http://cake-syrup.svn.sourceforge.net/viewvc/cake-syrup/trunk/app/models/behaviors/soft_deletable.php?view=markup

This is the link in which I got the SoftDeleteBehavior class from, However, when I refresh my browser I have an error on line 45 that has to do with the ife() function.

Can anyone help? Thanks.

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

Google Map interface question

So, I want to use Google maps on my project which makes use of a
Location model. In that model there is a longitude and latitude value.
Most of the tutorials I have looked at talk about how to place
markers on your map. What I want to do is use the map to allow people
to navigate to the location they are editing and set the longitude and
latitude based on the current center of the map giving an easy
interface for entering in such values. So it leads me to this
question: How do I get the long/lat values from the google map and
save those values to my database? Thanks.

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


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

Re: Paginating cached data

It's a 1.3 app, unfortunately. I've almost cracked it and will post back here - hopefully later today.

Jeremy Burns
Class Outfit

http://www.classoutfit.com

On 29 Apr 2012, at 14:25:09, AD7six wrote:



On Saturday, 28 April 2012 14:49:30 UTC+2, Jeremy Burns wrote:
I have a function that does a whole bunch of complex finds and calculations to produce an array, which is then cached. Some of the array keys contain meta data about how the calculation was done and some high level contents of the results. One of the array keys contains the actual results that I want to display and paginate. How can I read that array key from cache and paginate it in a view?


Cheers,

AD 

--
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

CakePHP 2.1.2 & 2.2.0-beta released

The CakePHP core team is proud to announce the immediate availability of both CakePHP 2.1.2 [1], and 2.2.0-beta [2]. 2.1.2 is a bugfix release for the 2.1.x branch, while 2.2.0-beta is the first release for 2.2.x.

## CakePHP 2.1.2 ##

There are a number of bugfixes in 2.1.2, the most notable of those changes is:

* `Set::insert()` now overwrites values that were previously string values.
* AuthComponent now uses `loginRedirect` as the default redirect location, should the session be empty.
* `CakeNumber::format()` now supports multiple bytes for thousands/decimals when using PHP lower than PHP 5.4
* A change to CakeSession was reverted to help solve issues with IE8 and sessions being lost.
* Fixed an issue with SQLServer + boolean columns.
* `DboSource::buildJoinStatement()` does not add the schema when the table is a subquery.
* SessionComponent::id() always returns the sessionid.  It will auto-start the session if necessary.
* Method checking in Model for `expression()` and `calculate()` is only done when required now.
* The testsuite now always uses the `test` datasource.  Previously, if you did not include any fixtures and ran tests that required the database, the default connection was used.
* URL fragments are no longer urlencoded.  This caused issues with client side frameworks like backbone.
* The return of L10n::get() consistently returns the language.
* HTML escaping for string urls on `css()` and `script()` was fixed.
* Warnings from saveAll() with an empty hasMany data set are fixed.
* Validation::decimal() accepts values like `10` and  `10.0`.
* FormHelper::postButton() no longer makes invisible buttons.
* The `$_FILES` array is now recursively reformatted. This fixes issues when file inputs are deeply nested.
* EmailComponent no longer double encodes addresses containing UTF-8 characters.
* `File::create()` no longer juggles umask. This was a workaround for file caching which is no longer needed.

## CakePHP 2.2.0-beta ##

Following hot on the heels of 2.1.0, the CakePHP team is proud to announce the beta release for 2.2.0. 2.2.x will be an API compatible release with 2.0.x, and 2.1.x.  All of the changes mentioned in the 2.1.2 release, are also be present in 2.2.0-beta.  We've decided to skip the standard `-dev` and `-alpha` releases, as we think the new features are relatively stable, and should be generally transparent when upgrading. A quick list of new features added in 2.2.0-beta:

### Timezone support for CakeTime utility

* Added "Config.timezone" param to configure global timezone for the application.
* CakeTime functions can now use timezone string or DateTimeZone object for user offsets
* The $userOffset parameter has been replaced with $timezone parameter in all relevant functions.
* Passing numeric offsets for $timezone parameter is still possible for backwards compatibility.
* New methods added: `CakeTime::toServer()` and CakeTime::timezone()`

### Support pagination for complex custom finders

Model `findCount()` will now pass `$query['operation'] = 'count'` for more flexibility.

In many cases custom finds already return correct counts for pagination, but 'operation' key allows more flexibility to build other queries, or drop joins which are required for the custom finder itself. As the pagination of custom find methods never worked quite well it required workarounds for this in the model level, which are now no longer needed

### ACL methods now part of Permission model

Now the Permission model has available all methods exposed in the AclComponent for easier permissions check
in the model layer.

### New Hash class

A new utility library `Hash` was added. It is intended as a replacement for the Set class featuring improved performance, and a more consistent API. All internal
calls to Set were replaced and Set has been deprecated and will be removed in the next major version.

Also added were Set::expand() and Hash::expand() to convert a plain list of dot separated keys into a nested array.

### Helper Lazy Loading

Helpers located in the app folder can now be lazy loaded, there is no need to declare helpers anymore in the `$helpers` controller
property if they are located in the app folder and you do not rely on them triggering any callback.

### Redis cache engine

A new cache engine was added to interface with a Redis server, which is similar to Memcache

### Cache groups

It is now possible to tag or label cache keys under groups. This makes it simpler to mass-delete cache entries associated to the same label. Groups are declared at configuration time when creating the cache engine

### Fatal error & console error handlers

You can now configure separate error handlers for console and fatal errors.  If you leave these configurations undefined the defaults will be used.
If you are using a custom error handler, it will now receive fatal error codes, in addition to the other types.

### Nested transaction support

Dbo datasources now supports real nested transactions. If you need to use this feature in your application, enable it using ConnectionManager::getDataSource('default')->useNestedTransactions = true;

### Dispatcher filters

Event listeners can now be attached to the dispatcher calls, those will have the ability to change the request information or the response before it is sent to the client.
`app/Config/bootstrap.php` should be changed to add configuration related to Dispatcher filters. If your application relies on assets in themes or plugins being dispatched, or if your are using the full page caching feature you *must* copy the relevant configuration to your bootstrap file. You need to add the following:

    <?php
    Configure::write('Dispatcher.filters', array(
        'AssetDispatcher',
        'CacheDispatcher'
    ));

Additionally, the new AssetDispatcher filter will return a 304 code if it can detect the browser has the asset cached already

### Other Changes

* Add charset() / headerCharset() methods to CakeEmail class
* Travis CI support
* Added support for 'on' validation key in FormHelper. This will set the required class accordingly depending on the type of operation (create or update)

Following the beta of 2.2.0, the core team will be focusing on solidifying 2.2.x towards a final release, and beginning inital work on the next release of CakePHP.

As always, thanks to the friendly CakePHP community for the patches, documentation changes and new tickets. Without you there would be no 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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

problem

hi, i have a problem with my apache2, when i type to my browser the localhost/cakephp/ this text appear

Not Found

The requested URL /cakephp was not found on this server.


Apache/2.2.20 (Ubuntu) Server at localhost Port 80


can you please help me? thanks

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

problem

hi, i have a problem with my apache2, when i type to my browser the localhost/cakephp/ this text appear

Not Found

The requested URL /cakephp was not found on this server.


Apache/2.2.20 (Ubuntu) Server at localhost Port 80


can you please help me? thanks

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

Re: DebugKit and ExceptionRenderer

Sorry, forgot to mention my versions, if that helps.
I'm running CakePHP v2.1.1 with the latest DebugKit version from git (bff3a9d1bb)

Kind regards, Ruud

On Sunday, April 29, 2012 8:55:18 PM UTC+2, Ruud Bijnen wrote:
Hi CakePHP gurus,

I was wondering if it's possible to have the DebugKit.Toolbar included on Error pages. Being able to see the fired queries would make developing the app that I'm working on a lot easier.

Of course I tried to find some more info but most of the search results on this topic are about the DebugKit not working at all. I already spent quiet some time trying to figure out a way to force the Toolbar to be rendered, but without luck. I was hoping some one that is a little more involved would be able to help or give some pointers.

As far as I can tell all related beforeRender() methods get called regardless if an Exception is thrown or not. Setting the Controllers viewClass to 'DebugKit.Debug' in the AppController::beforeRender() causes the DebugView::render() method to fire, but no Toolbar in the output :/.

Any help would be greatly appreciated.

Kind regards, Ruud

--
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: CakePHP training


This group/list isn't a contact for a company or organisation; it's just for discussion between CakePHP user developers.

For what you want, how about this:

or just this:

Cheers
Daniel


On Mon, Apr 30, 2012 at 2:18 AM, zer0_gravity <zr0_g@hotmail.com> wrote:
can you give me a schedule for possible CakePHP training and how well
are the training rated/recognize internationally?

--
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php


--
Daniel Baird
I've tried going to the XHTML <bar /> a few times, but it's always closed.

--
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: Can you dynamically change CSS for a layout per user?

Great, I will try them out.
Thanks!

On 4/29/2012 2:19 PM, lowpass [via CakePHP] wrote:
You don't need to create separate CSS files for each user. If the new
styles are very few you can use $this->Html->style() to include a new
style block. But don't add the users' styles to Config. Instead, save
a serialised array to the users table. Look at the Html::style()
method to see how the array is expected to look.

If you prefer to have separate CSS files for each user, create the
file ONCE when the user chooses what they want (however you're doing
that) and then store the filename (without extension) in the users
table. Then you will be able to get the name from
$this->Auth->user('css') (or whatever you name the column).

If storing css rules:

if ($css = $this->Auth->user('css'))
{
    $this->Html->style(unserialize($css));
}

If storing filenames:

if ($css = $this->Auth->user('css'))
{
    $this->Html->css("users/${css}");
}



On Sat, Apr 28, 2012 at 7:09 PM, bs28723
<[hidden email]> wrote:

> Thanks Michael.      I think I could solve the problem of having the code in
> every controller by doing.......
>
> class AppController extends Controller {
>    public function beforeRender() {
>             $newCss = $this->Config->getCss($username);
>
>             $file = new File('/webroot/css/users/" . $username, true, 0644);
>             $file->write($newCss);
>             $file->close;
>             $this->set('cssfile', '/webroot/css/users/" . $username);
>    }
> }
>
> in layouts/default.ctp
>
>   <?php echo $this->Html->css($cssfile, null, array('inline' => false));  ?>
>
> But --
>    Is there a way to add the CSS inline, and not create and write a new file
> each time?
>    with 100 users online at the same time, this could be a performance
> issue????
>
> Thoughts?
>
>
>
> On 4/28/2012 6:23 PM, Michael Gaiser [via CakePHP] wrote:
>
> Would it be possible to just put a test in your app_controller.php and
> then make use of it in your \View\Layouts\default.ctp file? That way
> all your pages get it by default and you do not need to drive yourself
> crazy with placing that code everywhere.
>
> ~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
> [hidden email] For more options, visit this group at
> http://groups.google.com/group/cake-php
>
>
> ________________________________
> If you reply to this email, your message will be added to the discussion
> below:
> http://cakephp.1045679.n5.nabble.com/Can-you-dynamically-change-CSS-for-a-layout-per-user-tp5672783p5673236.html
> To start a new topic under CakePHP, email [hidden email]
> To unsubscribe from CakePHP, click here.
> NAML
>
>
> ________________________________
> View this message in context: Re: Can you dynamically change CSS for a
> layout per user?
>
> Sent from the CakePHP mailing list archive at Nabble.com.
>
> --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> [hidden email] For more options, visit this group at
> http://groups.google.com/group/cake-php

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


To unsubscribe from this group, send email to
[hidden email] For more options, visit this group at http://groups.google.com/group/cake-php



If you reply to this email, your message will be added to the discussion below:
http://cakephp.1045679.n5.nabble.com/Can-you-dynamically-change-CSS-for-a-layout-per-user-tp5672783p5674444.html
To start a new topic under CakePHP, email [hidden email]
To unsubscribe from CakePHP, click here.
NAML


View this message in context: Re: Can you dynamically change CSS for a layout per user?
Sent from the CakePHP mailing list archive at Nabble.com.

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

Re: Hashing Password in CakePHP 2.1

you got this error because key 'password' didn't exists :)
--
Lep pozdrav, Tilen Majerle



2012/4/29 Charles Blackwell <charlesblackwell412@gmail.com>
$this->data['User']['password']

--
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: Hashing Password in CakePHP 2.1


I only have a form to create new users, so it would always be true.

My code was

public function beforeSave($created){
if($created)
  $this->data['User']['password'] = AuthComponent::password($this->data['User']['password']);
return true;
}

It didn't like that and I was still getting the error.
Notice (8): Undefined index: password [APP\Model\User.php, line 7]

Charles

On Sunday, April 29, 2012 3:41:31 PM UTC-4, Thiago Belem wrote:
$created is a beforeSave parameter:

public function beforeSave($created = false) {

}

Inside the method, $created will be true if the record was created and false if it's being updated... but this wouldn't work if you want to change the user password (since it's an update).

Regards,
--
Thiago Belem
Desenvolvedor
Rio de Janeiro - RJ - Brasil

Assando Sites - Curso online de CakePHP



On Sun, Apr 29, 2012 at 16:39, Charles Blackwell <charlesblackwell412@gmail.com> wrote:
I was trying to use $created because I saw it in book. I didn't know if it was a model property or not. That didn't work and I had a brain freeze, lol.


On Sunday, April 29, 2012 3:30:30 PM UTC-4, MaJerle.Eu wrote:
only PHP basics :)

public function beforeSave()
{
    if (isset($this->data['User']['password'])) {
    $this->data['User']['password'] = AuthComponent::password($this->data['User']['password']);
    }
    return true;
}


--
Lep pozdrav, Tilen Majerle



2012/4/29 Charles Blackwell <charlesblackwell412@gmail.com>
This works but, is there a way to NOT has the password when the confirm method is called? Also, in your opinion is beforeSave a good way to hash the password?

Thanks!

  1. <?php
  2.     class User extends AppModel {
  3.         public $name = 'User';
  4.        
  5.         public function beforeSave() {
  6.         $this->data['User']['password'] = AuthComponent::password($this->data['User']['password']);
  7.         return true;
  8.     }
  9.  
  10. <?php
  11.     App::uses('CakeEmail', 'Network/Email');
  12.     class UsersController extends AppController {       
  13.         public $name = 'Users';
  14.         public $components = array('Auth', 'Email');
  15.        
  16.         function beforeFilter(){
  17.             $this->Auth->allow('signup', 'confirm');
  18.         }
  19.  
  20.     function signup(){
  21.     if(!empty($this->request->data)){
  22.             $this->request->data['User']['confirm_code'] = String::uuid();
  23.                 $this->User->create();
  24.                 if($this->User->save($this->request->data)){
  25.                     $email = new CakeEmail();
  26.                     $email->template('welcome', 'default')
  27.                                 ->emailFormat('html')
  28.                                 ->viewVars(array(
  29.                                         'id' => $this->User->getLastInsertID(),
  30.                                         'username' => $this->request->data['User']['username'],
  31.                                         'email' => $this->request->data['User']['email'],
  32.                                         'server' => $_SERVER['SERVER_NAME'],
  33.                                         'code' => $this->request->data['User']['confirm_code']
  34.                                         ))
  35.                                 ->from(array('quickwall@localhost.com' => 'QuickWall.com Administrator'))
  36.                             ->to($this->request->data['User']['email'])
  37.                             ->subject('Welcome!');
  38.        if($email->send()){
  39.                         $this->Session->setFlash('Congratulations! You have signed up!');
  40.                         $this->redirect(array('controller' => 'questions', 'action' => 'home'));
  41.                     }
  42.                 } else {
  43.                     $this->Session->setFlash('There was an error signing up. Please, try again.');
  44.                     $this->request->data = null;
  45.                 }            
  46.             }
  47.         }
  48.        
  49.         function confirm($user_id=null, $code=null){
  50.             if(empty($user_id) || empty($code)){
  51.                 $this->set('confirmed', 0);
  52.                 $this-render();
  53.                 }
  54.            
  55.             $user = $this->User->read(null, $user_id);
  56.            
  57.             if(empty($user)){
  58.                 $this->set('confirmed', 0);
  59.                 $this->render();
  60.                 }
  61.            
  62.             if($user['User']['confirm_code'] == $code){
  63.                 $this->User->id = $user_id;
  64.                 $this->User->saveField('confirmed', '1');
  65.                 $this->set('confirmed', 1);
  66.                 } else {
  67.                     $this->set('confirmed', 0);
  68.                 }
  69.             }

--
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

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

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