CakeDC Search $filterArgs

2013-11-25 Thread Charles Blackwell
Can someone explain to me the filterArgs property? Is it like a pre-search 
filter? Am I restricting what users can search for?

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

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


Re: Best Practise - beforeValidate()

2013-11-22 Thread Charles Blackwell
You could use validation and create a custom method to validate to your 
specification.

http://book.cakephp.org/2.0/en/models/data-validation.html#custom-validation-rules

On Friday, 22 November 2013 18:43:34 UTC-5, advantage+ wrote:
>
> What is the best way when saving data for example take city or first name 
> field. 
>
> You want it to only be a-z and a space - or.(period)
>
>  
>
> Should you in beforeValidate do a preg_replace and remove anything that 
> you do not want then save(attempt) it or simply use the validation rules to 
> check and save / return false explaining why?
>
>  
>
> Just curious as to how people approach this and reasons for doing it 
> either way.
>
>  
>
> Thanks,
>
> Dave
>

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

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


Re: CakeDC Search plugin for CakePhp 2.0, multiple models

2013-11-22 Thread Charles Blackwell
Is your version different than the CakeDC version? The readme looks exactly 
the same.

CoderDJ412

On Friday, June 15, 2012 4:08:11 AM UTC-4, euromark wrote:
>
> try this one:
> https://github.com/dereuromark/search
>  
>
> it can handle multiple fields across models for a like term etc
>
> 'field' => array('Primary.field', 'Secondary.other_field')
>
>
> Am Freitag, 15. Juni 2012 00:06:03 UTC+2 schrieb Bob Bowen:
>>
>> Is there any way to make this work? As I understand it you have to 
>> enable Search.Searchable in the $actsAs, and define $filterArgs for each 
>> Model, then add Search.Prg to $components and define $presetVars in the 
>> Controller.
>>
>> Then in your .ctp file you put something like this:
>>
>> echo $this->Form->create('MyModel', array('url' => 
>> array_merge(array('action' => 'find'), $this->params['pass'])));
>> echo $this->Form->input('search', array('div' => false));
>> echo $this->Form->submit(__('Search', true), array('div' => false));
>> echo $this->Form->end();
>>
>> But this allows you to search in one Model at a time. Is there any way to 
>> define a search form with one search field and have it look in various 
>> fields within various Models?
>>
>> Thanks
>> Bob
>>
>

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

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


Re: CakeDC Search plugin for CakePhp 2.0, multiple models

2013-11-22 Thread Charles Blackwell
I got the same error and I was using related tables.

On Saturday, June 16, 2012 7:13:03 PM UTC-4, Bob Bowen wrote:
>
> Hi and thanks for the reply.
>
> Yea, I had seen this plugin, it's a fork of the CakeDC plugin. And I see 
> in the docs that you can do something like this:
>
> class Article extends AppModel {
>   public $filterArgs = array(
> 'enhanced_search' => array('type' => 'like', 'field' => 
> array('Article.name', 'OtherModel.name'))
>   }
> }
>
> But what is not explained is, how do I get the plugin to actually search 
> within the 'OtherModel' Model? I ask because later in the Controller you 
> have:
>
> class ArticlesController extends AppController {
> public $components = array('Search.Prg');
>
> public $presetVars = true; // using the model configuration
>
> public function find() {
> $this->Prg->commonProcess();
> $this->paginate['conditions'] = $this->*Article*
> ->parseCriteria($this->passedArgs);
> $this->set('articles', $this->paginate());
> }
> }
>
> And in the .ctp you have:
>
> echo $this->Form->create('*Article*', array(
> 'url' => array_merge(array('action' => 'find'), $this->params['pass'])
> ));
>
> As you can see, the Article Model is always referenced. So if I want to 
> search for a field from another model, like the 'OtherModel.name' example 
> above, it crashes, saying:
>
> Column not found: 1054 Unknown column ' OtherModel.name ' in 'where clause'
>
> The SQL is more or less:
>
> SELECT `Article`.`id`, ... FROM `articles` WHERE ((`Article`.`name` LIKE 
> '%foo%') OR (`OtherModel`.`name` LIKE '%foo%')) 
>
> Obviously OtherModel.name is not going to be found in Article. 
>
> What I need to do is have a general Search box that searches in 4-5 
> different Models. There is no relation between those Models. So I am not 
> sure which Model to put the filterArgs array, which Controller to put the 
> presetVars array and find() function, and how to call it all in my .ctp so 
> that it can return results from all 5 of these Models, not just one.
>
> Can this plugin do it?
>
> Many thanks!
>
> On Friday, June 15, 2012 10:08:11 AM UTC+2, euromark wrote:
>>
>> try this one:
>> https://github.com/dereuromark/search
>>  
>>
>> it can handle multiple fields across models for a like term etc
>>
>> 'field' => array('Primary.field', 'Secondary.other_field')
>>
>>
>> Am Freitag, 15. Juni 2012 00:06:03 UTC+2 schrieb Bob Bowen:
>>>
>>> Is there any way to make this work? As I understand it you have to 
>>> enable Search.Searchable in the $actsAs, and define $filterArgs for each 
>>> Model, then add Search.Prg to $components and define $presetVars in the 
>>> Controller.
>>>
>>> Then in your .ctp file you put something like this:
>>>
>>> echo $this->Form->create('MyModel', array('url' => 
>>> array_merge(array('action' => 'find'), $this->params['pass'])));
>>> echo $this->Form->input('search', array('div' => false));
>>> echo $this->Form->submit(__('Search', true), array('div' => false));
>>> echo $this->Form->end();
>>>
>>> But this allows you to search in one Model at a time. Is there any way 
>>> to define a search form with one search field and have it look in various 
>>> fields within various Models?
>>>
>>> Thanks
>>> Bob
>>>
>>

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

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


Re: What code to put for using the CakeDC search plugin?

2013-11-15 Thread Charles Blackwell
Finally got it working!!!

It must have been my version of Cake or something but we're in there!

Finally!

On Tuesday, December 13, 2011 5:28:16 PM UTC-5, Daniel wrote:
>
> I want to do a search on fields in two tables, body and title fields
> (in posts table) and body field (in comments table).  I have installed
> the CakeDC search plugin.  In the models I have added the 'Searchable'
> code:
>
> var $actsAs = array('Containable', 'Searchable');
>
> I am trying to follow the page on the CakeDC site:
> http://cakedc.com/eng/downloads/view/cakephp_search_plugin
>
> ... but I don't understand the example.
>
> What should I put next in the model?
>
> Thanks.
>
>

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

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


Re: What code to put for using the CakeDC search plugin?

2013-11-15 Thread Charles Blackwell
Yes, I followed the readme.

I've added the plugin, the behavior and component. I am stuck on the 
filterArgs properties.

Here's my model code:

App::uses('Security', 'Utility');
App::uses('SearchableBehavior', 'Search.Model/Behavior');
App::uses('AppModel', 'Model');

class Venue extends AppModel {

  public $name = 'Venue';
  public $actAs = array(
'Containable',
'Search.Searchable');

  public $filterArgs = array(
'name' => array('type' => 'like')
  );

//Controller code:

public function find(){
$this->Prg->commonProcess();
$this->Paginator->settings['conditions'] = 
$this->Venue->parseCriteria($this->Prg->parsedParams());
$this->set('venues', $this->Paginator->paginate());
  }

//View code
echo $this->Form->create('Venue', array(
'url' => array_merge(array('action' => 'find'), $this->params['pass'])
  ));
  echo $this->Form->input('name', array('div' => false));
  echo $this->Form->submit(__('Search'), array('div' => false));
  echo $this->Form->end();

Error recieved:

*Notice* (8): Array to string conversion 
[*CORE\Cake\Model\Datasource\DboSource.php*, line *460*]

*Error: *SQLSTATE[42000]: Syntax error or access violation: 1064 You have an 
error in your SQL syntax; check the manual that corresponds to your MySQL 
server version for the right syntax to use near 'parseCriteria' at line 1

*SQL Query: *parseCriteria

Onn Friday, November 15, 2013 6:36:31 AM UTC-5, euromark wrote:

Did you follow the readme?

You need to be more specific when you ask a question - ideally including 
> what you already tried so far.
>
> Am Freitag, 15. November 2013 05:32:13 UTC+1 schrieb Charles Blackwell:
>>
>> Do you need a create a search function of some sort to get it to work? I 
>> am stuck on how to get it working.
>>
>> On Tuesday, December 13, 2011 6:51:30 PM UTC-5, Daniel wrote:
>>>
>>> OK, forget it, I got a basic search up and running now.
>>>
>>

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

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


CakeDC Search: Filter Method

2013-11-15 Thread Charles Blackwell
Do I need to add a filter method for the search plugin to work?

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

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


Re: What code to put for using the CakeDC search plugin?

2013-11-14 Thread Charles Blackwell
Do you need a create a search function of some sort to get it to work? I am 
stuck on how to get it working.

On Tuesday, December 13, 2011 6:51:30 PM UTC-5, Daniel wrote:
>
> OK, forget it, I got a basic search up and running now.
>

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

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


CakePHP BlueHost Shared Hosting

2013-09-13 Thread Charles Blackwell
I am having a little trouble getting my set up and wondered if you could 
help.

The directory structure is as follows:
public_html/
->App
->Lib
->Webroot
->gallery (non-cakephp)

etc.

I am having difficulty because cakephp has taken over the whole site and I 
only want it to respond to the main folder but it does it to my subdomain 
folders as well.

What should I do?

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

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


Re: JsHelper CakePHP 2.1

2012-05-07 Thread Charles Blackwell
I just wanted to know how to do a simple script. For example, do I use 
scriptStart and scriptEnd to enclose the domReady event?

On Monday, May 7, 2012 8:20:03 AM UTC-4, manzapanza wrote:
>
> CakePHP 2.1 natively supports jquery
> http://book.cakephp.org/2.0/en/core-libraries/helpers/js.html
> What you need to do with JsHelper?
>
> Il giorno giovedì 3 maggio 2012 02:11:28 UTC-3, Charles Blackwell ha 
> scritto:
>>
>> Are there any tutorials available for the JsHelper for CakePHP 2.1 yet?
>
>

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


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


Re: Problem with JsHelper

2012-05-02 Thread Charles Blackwell
You need to switch these two around:

> I have a problem with Js that I cannot resolve. I am basically trying 
> to write a "Hello, world" app to learn how to use this feature. 
>
> When I click on my submit button the first time, everything works. 
> When I click on the same button the second time, it blows up trying to 
> go to what appears to be a "null" controller: 
>
> Missing Controller 
> Error: Controller could not be found. 
> Error: Create the class Controller below in file: app/Controller/ 
> Controller.php 
>  class Controller extends AppController { 
> } 
>
> Here is my Controller: 
>
> public function check($id = false) { 
> if (!empty($this->request->data)) { 
> if ($this->RequestHandler->isAjax()) { 
> $this->set('result', 'Hello, world'); 
> $this->render('result', 'ajax'); 
> } 
> } 
> } 
>
> Here is my View: 
>
> Html->script('jquery', array('inline' => false)); ?> 
>  echo $this->Form->create(); 
> echo $this->Js->submit('Check', array('update' => 
> '#success')); 
> echo $this->Form->end(); 
> ?> 
>  
> Checking... 
> Js->writeBuffer(); ?> 
>
> JsHelper is generating the following JavaScript: 
>
> script type="text/javascript"> 
> // 
>  
>
> I'm stumped why it works on the first click but not the second. 
>
>

-- 
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: Hashing Password in CakePHP 2.1

2012-04-29 Thread Charles Blackwell

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*
> assando-sites.com.br <http://goo.gl/b1EEd>
>
> thiagobelem.net
> cont...@thiagobelem.net
>
> *Skype / gTalk **»* thiago.belem.web
> *LinkedIn* *»* br.linkedin.com/in/thiagobelem/pt
>
>
>
> On Sun, Apr 29, 2012 at 16:39, Charles Blackwell <
> charlesblackwell...@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
>>> http://majerle.eu
>>>
>>>
>>>
>>> 2012/4/29 Charles Blackwell 
>>>
>>>> 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. >>>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. >>>11. App::uses('CakeEmail', 'Network/Email');
>>>>12. class UsersController extends AppController {
>>>>13. public $name = 'Users';
>>>>14. public $components = array <http://www.php.net/array>(
>>>>'Auth', 'Email');
>>>>15. 
>>>>16. function beforeFilter(){
>>>>17. $this->Auth->allow('signup', 'confirm');
>>>>18. }
>>>>19.  
>>>>20. function signup(){
>>>>21. if(!empty <http://www.php.net/empty>($this->request->data**)
>>>>){
>>>>22. $this->request->data['User']['**confirm_code'] = 
>>>>String::uuid();
>>>>23. $this->User->create();
>>>>24. if($this->User->save($this->re**quest->data)){
>>>>25. $email = new CakeEmail();
>>>>26. $email->template('welcome', 'default')
>>>>27. ->emailFormat('html')
>>>>28. 
>>>> ->viewVars(array<http://www.php.net/array>
>>>>(
>>>>29. 'id' => $this->User->
>>>>getLastInsertID()**,
>>>>30. 'username' => $this->
>>>>request->data['User']['**username'],
>>>>31. 

Re: Hashing Password in CakePHP 2.1

2012-04-29 Thread Charles Blackwell
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
> http://majerle.eu
>
>
>
> 2012/4/29 Charles Blackwell 
>
>> 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. >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. >11. App::uses('CakeEmail', 'Network/Email');
>>12. class UsersController extends AppController {
>>13. public $name = 'Users';
>>14. public $components = array <http://www.php.net/array>(
>>'Auth', 'Email');
>>15. 
>>16. function beforeFilter(){
>>17. $this->Auth->allow('signup', 'confirm');
>>18. }
>>19.  
>>20. function signup(){
>>21. if(!empty <http://www.php.net/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<http://www.php.net/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<http://www.php.net/array>
>>('quickw...@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<http://www.php.net/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 <http://www.php.net/empty>($user_id) || 
>> empty<http://www.php.net/empty>
>>($code)){
>>51.

Re: Hashing Password in CakePHP 2.1

2012-04-29 Thread Charles Blackwell
I am still very new to PHP and Cake.

On Sunday, April 29, 2012 3:32:21 PM UTC-4, MaJerle.Eu wrote:
>
> Yep...cake's book says that you should there hash password :)
> --
> Lep pozdrav, Tilen Majerle
> http://majerle.eu
>
>
>
> 2012/4/29 Tilen Majerle 
>
>> 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
>> http://majerle.eu
>>
>>
>>
>> 2012/4/29 Charles Blackwell 
>>
>>> 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. >>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. >>11. App::uses('CakeEmail', 'Network/Email');
>>>12. class UsersController extends AppController {
>>>13. public $name = 'Users';
>>>14. public $components = array <http://www.php.net/array>(
>>>'Auth', 'Email');
>>>15. 
>>>16. function beforeFilter(){
>>>17. $this->Auth->allow('signup', 'confirm');
>>>18. }
>>>19.  
>>>20. function signup(){
>>>21. if(!empty <http://www.php.net/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<http://www.php.net/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<http://www.php.net/array>
>>>('quickw...@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<http://www.php.net/array>
>>>('controller' => 'questions', 'action' => 'home'));
>>>41. }
>>>42. } else {
>>>43. $this->Session->setFlash('There was an error 
>>>signing up. Please, try again.');
>>>44.

Re: Hashing Password in CakePHP 2.1

2012-04-29 Thread Charles Blackwell
Thanks :)

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
> http://majerle.eu
>
>
>
> 2012/4/29 Charles Blackwell 
>
>> 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. >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. >11. App::uses('CakeEmail', 'Network/Email');
>>12. class UsersController extends AppController {
>>13. public $name = 'Users';
>>14. public $components = array <http://www.php.net/array>(
>>'Auth', 'Email');
>>15. 
>>16. function beforeFilter(){
>>17. $this->Auth->allow('signup', 'confirm');
>>18. }
>>19.  
>>20. function signup(){
>>21. if(!empty <http://www.php.net/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<http://www.php.net/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<http://www.php.net/array>
>>('quickw...@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<http://www.php.net/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 <http://www.php.net/empty>($user_id) || 
>> empty<http://www.php.net/empty>
>>($code)){
>>51. $this->set('confirmed', 0);
>>52. $this-render();
>>53. }
>>54.  

Re: Model Data on the home.ctp

2011-09-24 Thread Charles Blackwell
Here's my code and the errors that cakephp gives me:
class PagesController extends AppController {
var $name = 'Pages';
var $helpers = array('Html');
var $uses = array('Post');

function display() {
$path = func_get_args();

$count = count($path);
if (!$count) {
$this->redirect('/');
}
$page = $subpage = $title_for_layout = null;

if (!empty($path[0])) {
$page = $path[0];
}
if (!empty($path[1])) {
$subpage = $path[1];
}
if (!empty($path[$count - 1])) {
$title_for_layout = Inflector::humanize($path[$count -
1]);
}
//$posts = $this->Post->find('all');
$this->set(compact('page', 'subpage',
'title_for_layout'));
$this->render(implode('/', $path));
}

function home(){
$posts = $this->Post->find('all');
$this->set(compact('posts'));
}
}


//home.ctp


>
�
�





//cakephp errors
Notice (8): Undefined variable: posts [APP\views\pages\home.ctp,
line 4]
Warning (2): Invalid argument supplied for foreach() [APP\views
\pages\home.ctp, line 4]

On Sep 24, 12:09 pm, Charles Blackwell 
wrote:
> So it looks like the $uses attribute will do the trick. But, are those
> models that I enable via the attribute available to all of my pages in
> the pages directory? Say for example, I created an about.ctp. Would
> the model be available in that about view as well?
>
> Charles
>
> On Sep 24, 11:22 am, Charles Blackwell 
> wrote:
>
>
>
>
>
>
>
> > How can I display data on the home.ctp template? Do I use the set
> > method on the pages controller?

-- 
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: Model Data on the home.ctp

2011-09-24 Thread Charles Blackwell
So it looks like the $uses attribute will do the trick. But, are those
models that I enable via the attribute available to all of my pages in
the pages directory? Say for example, I created an about.ctp. Would
the model be available in that about view as well?

Charles

On Sep 24, 11:22 am, Charles Blackwell 
wrote:
> How can I display data on the home.ctp template? Do I use the set
> method on the pages controller?

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


Model Data on the home.ctp

2011-09-24 Thread Charles Blackwell
How can I display data on the home.ctp template? Do I use the set
method on the pages controller?

-- 
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: Saving Related Models

2011-07-24 Thread Charles Blackwell
The model relation that I need is User hasOne Profile. So, could I do
this to save the user and the profile at the same time:

echo $form->create('User', array('action'=>'add'));
echo $form->input('User.username', array('label'=>'Username:'));
echo $form->input('User.password');
echo $form->input('Profile.first_name', array('label'=>'Profile'));
echo $form->input('Profile.last_name');
echo $form->input('Profile.email');

Thanks.


On Jul 22, 5:40 pm, Jens Dittrich  wrote:
> Because Company hasMany Account... the example implies that you want to save
> the first Account along with the new entry of a company.

-- 
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: Saving Related Models

2011-07-24 Thread Charles Blackwell
Ok, thanks for your answer. But to make sure I am understanding you
correct. Let's say I wanted to add 3 accounts belonging to a company
using this form. Would this be the correct way to do so:

echo $form->create('Company', array('action'=>'add'));
echo $form->input('Company.name', array('label'=>'Company name'));
echo $form->input('Company.description');
echo $form->input('Company.location');
//Account #1
echo $form->input('Account.0.name', array('label'=>'Account #1
Name'));
echo $form->input('Account.0.username');
echo $form->input('Account.0.email');
//Account #2
echo $form->input('Account.1.name', array('label'=>'Account #2
Name'));
echo $form->input('Account.1.username');
echo $form->input('Account.1.email');
//Account #3
echo $form->input('Account.2.name', array('label'=>'Account #3
Name'));
echo $form->input('Account.2.username');
echo $form->input('Account.2.email');
echo $form->end('Add');

Thanks again for your help!

Charles

On Jul 22, 5:40 pm, Jens Dittrich  wrote:
> Because Company hasMany Account... the example implies that you want to save
> the first Account along with the new entry of a company.

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


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


Saving Related Models

2011-07-21 Thread Charles Blackwell
In the example below, why does Account input have a zero between the
model and field name?

echo $form->create('Company', array('action'=>'add'));
echo $form->input('Company.name', array('label'=>'Company name'));
echo $form->input('Company.description');
echo $form->input('Company.location');
echo $form->input('Account.0.name', array('label'=>'Account name'));
echo $form->input('Account.0.username');
echo $form->input('Account.0.email');
echo $form->end('Add');

Thanks,

Charles

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


Bakery Registration/Login Not Working

2010-08-24 Thread Charles Blackwell
I authenticated my Bakery account and tried to log in, no dice. I
reset the password...still, no dice. What do I do now?

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


Investment Software

2010-07-16 Thread Charles Blackwell
Hi. I am kinda new to PHP and very new to Cake and OOP. I want to
develop a simple interface to track investments in a company. The app
would support a number of investors. I want the app to have a profile
page for each investor that displays their info such as name, start
date, initial investment and interest earned.

>From what I have read, it looks like I would need to develop a user
module and a transaction module. The user module obviously would be
where I stored all my user information. I thinking the transaction
module would be where I store things like interest earned, account
withdraws, etc.

Also, I will need some authentication with this since it would be
using sensitive data.

Does that look about right? Do you think that I would need anything
else to accomplish this programming task?
Can someone help guide me through this project?

Thanks.

C

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