Tuesday, December 31, 2013

Ajax and Assets Question

Not sure if this is possible or just could not find the correct answer I was looking for.

 

ISSUE:

I have the site which uses various additional js scripts throughout the site. What I have is in my layouts is I load the absolute global required css and js and compress them.

Layouts/default.ctp

 

$this->Less->prepend(array('bootstrap.min.css', 'styles.less', 'admin.less', 'typography.less', 'jquery.fancybox.css'));

echo $this->Less->compile($options = array());

                               

$this->Compressor->prepend_libs('js', array(

                'jquery-1.9.1.min',

                'bootstrap.min',

                'admin',

                'jquery.fancybox'));

                                               

echo $this->Compressor->scripts('js');

 

And then in my pages if I need an upload script or anything special I simply in that view add the css / js where needed on demand specific for that page. And it will create a single css / js files from the layout and view and cache it so it's only compile once or if changed

 

random_view.ctp

/*

additional js and css for page

*/

//$this->Less->add(array('uploader.css'));

$this->Compressor->add_libs('js', array(

                'autoUploader',

                'jquery.blockUI',

                'jquery.form'));

 

PROBLEM:

 

I want to load 95% of these pages in the admin backend section via ajax.

But then none of the javascripting functionality works because it is not grabbing the javascript. The actual "base" page loads the initial css and js but loading new pages into the "content" area which need additional scripting will not work.

So if for example I click on my image gallery link it will load the page into the main section of the site. Uploader script is required for this page. Cluck upload => upLoader() is not a function. Because the required upload script is never actually pulled.

 

Any ideas guys? I cannot / do not want to add all the scripts on 1 page (size and conflict between scripts, so not really an option)

 

Thanks

Dave

Is it possible to do watch window debugging of cakephp code?

Are there any debugger that allows one to trace our code on a watch window for cakephp?

Thank you.

--
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+unsubscribe@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.

Sunday, December 29, 2013

Re: Security Component Question

Check the Code http://api.cakephp.org/2.4/source-class-SecurityComponent.html#322-338

Blackholing is nothing more than throwing a BadRequestException or triggering a callback.

I would not use an exception in that place.

On Friday, December 27, 2013 7:37:24 PM UTC+1, advantage+ wrote:

Is there a way to force call blackhole based on model validation rules?

 

I have a validation method that I would like to call the blackhole if it fails.

 

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+unsubscribe@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.

How to respond based on request method?

Trying to sort this out but not getting anywhere.

 

I need to respond based on how the request was made.

 

So first I need to know if the data was saved:

 

$saved = $this->User->save($this->Controller->request->data, true, $forceFields);

Then return the saved / error message back to the user.

 

But then it gets messy and just looks wrong. Has to be a correct was as this clearly is not it. (ajax response gets sent back as a JSON response)

 

SNIP FROM COMPONENT IN A PLUGIN (but gives you an idea)

 

if ($saved && !$this->Controller->request->is('ajax')) {

                                                               

                $this->Session->setFlash(__('Good stuff saved via HTTP request.'));

                                                               

} else {

                                                               

                $this->Session->setFlash(__('Nope via HTTP.'));

                $this->Controller->redirect(array('action' => 'index'));

}

                                               

                                               

if ($saved && $this->Controller->request->is('ajax')) {

                                                               

                $response = array(

                                'status' => true,

                                'clear' => true,

                                'message' => 'Good stuff saved via ajax.');

                                                               

} else {

 

                $response = array(

                                'clear' => false,,

                                'message' => 'Nope via ajax.');

}

 

Thanks,

Dave

Re: Dealing With Malicious Users

I think it really depends on the developer, I would recommend using setFlash and redirect or even throwing an appropriate exception for simple enough applications.

You could also write to a log file when you suspect malicious activity and take note of any parameters or auth session details for review.

I would personally say don't try to auto ban or log them out it probably wont stop them.

HTH
 Stephen

Sent from my iPad

On 29 Dec 2013, at 23:19, "Advantage+" <movepixels@gmail.com> wrote:

I am working on a fairly large application and I am modify form fields, trying to edit other people's records or just stuff you should not be doing to test things out.

 

My question is how to handle these requests.

Obviously what they are doing gets stopped but do you alert them with a message Illegal Attempt? Log them out? Ban them? Record the error for admin to review and decide later what to do.

Simply dis-regard and do nothing and just a message saying error please try again?

 

If someone is up to no good what is the best way to deal with this? How do you handle it? What do you do?

 

Thanks for any and all insight you guys can provide.

 

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+unsubscribe@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.

Dealing With Malicious Users

I am working on a fairly large application and I am modify form fields, trying to edit other people's records or just stuff you should not be doing to test things out.

 

My question is how to handle these requests.

Obviously what they are doing gets stopped but do you alert them with a message Illegal Attempt? Log them out? Ban them? Record the error for admin to review and decide later what to do.

Simply dis-regard and do nothing and just a message saying error please try again?

 

If someone is up to no good what is the best way to deal with this? How do you handle it? What do you do?

 

Thanks for any and all insight you guys can provide.

 

Dave

 

 

CakePHP Community 2013

We've been very busy, and have a lot to show for it. Late last year we created the Community Center, as a central location for everyone to find their way around, and help people get involved with the project. This year we launched My CakePHP, as a hub for developers to create a profile, and unify the experience across all of our sites. The Cake Software Foundation website also received a well overdue facelift. Additionally, after continuous requests, and with a little help from CakeDC, we improved the schedule for the official CakePHP training, which is now provided on a regular basis.

Earlier this year we also announced our agreement with Microsoft to make CakePHP available on Windows Azure. That doesn't mean you can't get your piece of the cake on other platforms, such as Rackspace's Cloud Sites, Amazon's Elastic Beanstalk or RedHat's OpenShift, as well as other PaaS providers, like Pagoda Box or Fortrabbit. There's a lot to choose from.

It was also great to see that, since our efforts last year to extend the reach of the CakePHP community, both the Facebook interest page and our official Twitter account have reached over 10,000 likes and followers each. The official group on Facebook also surpassed 3,000 members, becoming even larger than groups for other major PHP frameworks. But the growth didn't stop there. We had almost 1 million more visits to the CakePHP sites compared to last year, with the CookBook seeing nearly an additional 10 million page views, reaching over 26 million. For more numbers and stats check out this year's community keynote.

Which takes us to San Francisco, USA, where we held CakeFest 2013, the annual conference dedicated to everything CakePHP. Over 80 developers from around the world joined us for 4 days of workshops and conference. We listened to your feedback from the previous year and broke the workshop schedule into beginner and advanced sessions over the first 2 days. This was then followed by another 2 days of 16 talks given by 12 international speakers, as well as keynotes, lightning talks, core team Q&A, and the raffle. We took away some really memorable moments, the best of all being the "Hour of Contribution", where we saw everyone contributing to the project for an hour, in true open source fashion. It was a beautiful sight, and a humbling experience. Oh, and who could forget about the cake!

But wait, there's more. Work has been going strong on version 3.0 of CakePHP, with the new ORM almost ready for it's first developer preview release. The roadmap is slowly being completed, with the milestone available for anyone to join in on the fun. In the meantime, this year saw the release of versions 2.3 and 2.4 of the framework, with a sum of 28 releases in total. There's also been a lot of activity in the developer community, with almost 6,000 additional questions tagged on Stack Overflow this past year alone. We also saw some interesting projects released, a couple of videos, interviews and books published, a few useful tools, as well as some nice cheat sheets. Not to mention some great initiatives, and of course, an honorable mention to core member Jose Gonzalez, who delivered a total of 25 successive posts on his blog as part of his CakePHP advent series. For all our Japanese developers, there was a similar series created previous years.

Overall, 2013 was an amazing year, and one to be proud of as a member of the community! A big thank you goes out to everyone who has been involved and helped make CakePHP what it is - a framework built by the community! Thank you.

Link: http://bakery.cakephp.org/articles/jameswatts/2013/12/29/cakephp_community_2013

--
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+unsubscribe@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.

Saturday, December 28, 2013

RE: missing debug menu

I think you are referring to the Debug Kit?

You have to have the DebugKit in your Plugin folder then load it in your bootstrap file.

 

Config/bootstrap.php:

CakePlugin::load('DebugKit');

 

Dave

 

From: cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] On Behalf Of roundrightfarm
Sent: Saturday, December 28, 2013 1:24 PM
To: cake-php@googlegroups.com
Subject: missing debug menu

 

Greetings,

I just switched from cakephp 1.3 to 2.x.  in 1.3 there was a debug menu that would appear when Configure::write('debug', 2);  It was a pop-out menu that started in the upper right hand corner of the screen and would show you, among other things, which variables were set to a view.

 

Is this menu gone from cakephp 2.x, or am I missing something

 

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+unsubscribe@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: missing debug menu

This is the DebugKit plugin, see here: https://github.com/cakephp/debug_kit

You may already have it in your plugins folder so maybe you just need to update bootstrap, see the instructions on the link above

Thanks
 Stephen


On 28 December 2013 16:54, roundrightfarm <roundrightfarm@gmail.com> wrote:
Greetings,
I just switched from cakephp 1.3 to 2.x.  in 1.3 there was a debug menu that would appear when Configure::write('debug', 2);  It was a pop-out menu that started in the upper right hand corner of the screen and would show you, among other things, which variables were set to a view.

Is this menu gone from cakephp 2.x, or am I missing something

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+unsubscribe@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.



--
Kind Regards
 Stephen Speakman

--
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+unsubscribe@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.

missing debug menu

Greetings,
I just switched from cakephp 1.3 to 2.x.  in 1.3 there was a debug menu that would appear when Configure::write('debug', 2);  It was a pop-out menu that started in the upper right hand corner of the screen and would show you, among other things, which variables were set to a view.

Is this menu gone from cakephp 2.x, or am I missing something

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+unsubscribe@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.

Security Component Help

I want to make action requests more secure by implementing the Restricting HTTP methods { requirePost(),requireGet(), requirePut(), requireDelete()} but running into a bit of an issue.

For an add request for example via ajax I have to fetch the form (get) and load it into the colorbox, and save the input gets sent as post. So the add method invokes 2 separate HTTP methods.

Other than break the public function add() into 2 separate functions such as

public function load() // fetch the form via get

and then
public function save()// post to save the data

Is there another way to accomplish this without having to break up the function?

I currently have:

public function save(){

                //load the form

                if($this->request->is('ajax') && $this->request->is('get')) {

                                …

                }

 

                //save the form

                if (!empty($this->request->data) && $this->request->is('post')) {

                                ….

                }

}

 

Any ideas anyone the best way to handle this?

Thanks,

 

Dave

 

Friday, December 27, 2013

Security Component Question

Is there a way to force call blackhole based on model validation rules?

 

I have a validation method that I would like to call the blackhole if it fails.

 

Thanks,

Dave

Thursday, December 26, 2013

Re: List of all Users belonging to Company?

Set up your paginate just as you would a normal search using the logged in users 'company_id' as the search criteria.

$this->paginate = array(
    'conditions' => array(
        'User.company_id' => $this->Auth->user('company_id')));

$this->set('users', $this->Paginator->paginate());

I believe that should do it if I'm not mistaken. 

On Tuesday, December 24, 2013 1:19:04 PM UTC-5, Shahana Ely wrote:
I have a Model of Users,
and a Model of Companies

each User belongs to a Company:
   public $belongsTo = 'Company';

each Company has many Users:
 public $hasMany = 'User';

A user logs in. It's an ordinary user (not an administrator).

I'm in the UsersController.php, function index, and I want to display only other users that belong to the same company the logged in user belongs to. How do I fetch that info?

e.g.
$this->set('users', $this->Paginator->paginate());

will display all users. Suitable for admin users, not for regular users. How do I restrict the list of users to only users belonging to the same company the user belongs to?

--
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+unsubscribe@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: Cakephp Radio Buttons from Database Entries

In your Complaint model, set 'description' as your displayField.

In your Controller, you will need to do a $this->Complaint->find('list') and pass the result $complaints into the view.

In your View, you will need to echo a $this->Form->input('complaint_id', array('type' => 'radio'))

On Thursday, December 26, 2013 11:08:24 AM UTC+8, John Michael Tejano wrote:
I have a database table called Complaints which has the following fields id and description. Is it possible that the values in the complaints table be used as radio button input fields? Such as if the table contains 10 entries there will be 10 radio buttons.

--
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+unsubscribe@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.

Wednesday, December 25, 2013

Cakephp Radio Buttons from Database Entries

I have a database table called Complaints which has the following fields id and description. Is it possible that the values in the complaints table be used as radio button input fields? Such as if the table contains 10 entries there will be 10 radio buttons.

--
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+unsubscribe@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.

Tuesday, December 24, 2013

List of all Users belonging to Company?

I have a Model of Users,
and a Model of Companies

each User belongs to a Company:
   public $belongsTo = 'Company';

each Company has many Users:
 public $hasMany = 'User';

A user logs in. It's an ordinary user (not an administrator).

I'm in the UsersController.php, function index, and I want to display only other users that belong to the same company the logged in user belongs to. How do I fetch that info?

e.g.
$this->set('users', $this->Paginator->paginate());

will display all users. Suitable for admin users, not for regular users. How do I restrict the list of users to only users belonging to the same company the user belongs to?

--
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+unsubscribe@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.

Chosen Implementation

Hi

I try to use Chosen plugin (https://github.com/paulredmond/chosen-cakephp) in my CakePHP project. What i've done is:

1)Download package and extract to 'Chosen' folder inside ...app/plugin folder
2)Load the plugin on bootstrap.php file: CakePlugin::load('Chosen');
3)insert the public helper at AppController file: public $helpers = array('Chosen.Chosen',);
4)Test my input file with:

echo $this->Chosen->select(
    'Article.category_id',
    array(1 => 'Category 1', 2 => 'Category 2'),
    array('data-placeholder' => 'Pick categories...', 'multiple' => true)
);

But nothing happen. the output still the same cakephp standard list. I'm sure it is not complete yet since in the documentation, its tell about composer.phar and composer.json etc. can anyone help me to implement the composer properly or maybe other things that affect the Chosen plugin to work appropriately. 

I'm using CakePHP version 2.3.1 (a bit outdated)

Thank you :)

--
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+unsubscribe@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.

Monday, December 23, 2013

CakePHP 2.4.4 released

The CakePHP core team is proud to announce the immediate availability of CakePHP 2.4.4. 2.4.4 is a bugfix release for the 2.4 release branch. A short list of the changes you can expect is:

* TextHelper::autoLink() now handles email addresses inside URLs correctly.
* Pagination request data is set even when a NotFoundException is raised now.
* Model::deleteAll will only delete distinct records now.
* Router::mapResources() now ensures that the prefix has both the leading and trailing slash.
* An infinite loop condition in CakeSession was fixed. This could be triggered by starting an already invalidated session.
* Hash::numeric() now works as expected with negative numbers and other numeric values.
* The 'my' and 'ym' formats for Validation::date() have been relaxed to allow both 2 and 4 digit year values.
* FormHelper will not infer types incorrectly when type=checkbox is provided.
* Postgres biginteger primary keys now correctly use the bigserial type.
* FormHelper::dateTime() correctly handles times around 12:00:00 when an interval is also used.
* Hash::combine() now throws exceptions when the key and value paths result in arrays of differing lengths.
* CakeRequest::referer() no longer incorrectly reads the HTTP_X_FORWARDED_HOST header.
* CakeRequest::host() now has a trustProxy parameter that allows access to the proxy host value.

You can view the full changelog on cakephp.org[1]. I'd like to thank the people who have contributed to this release. Your bug tickets, documentation edits, and patches/pull requests are a big part of what keeps CakePHP alive and ticking. Download a packaged release on github[2].

### Links

* [1] http://cakephp.org/changelogs/2.4.4
* [2] https://github.com/cakephp/cakephp/releases/2.4.4

--
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+unsubscribe@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.

Sunday, December 22, 2013

Re: Initiating a 'DELETE' or 'POST' in a folder inside webroot



On Saturday, 21 December 2013 13:31:38 UTC+1, Charles Martin Mendez wrote:
Hi,

I am using the fileupload jquery library. I was able to get everything working and migrated some functions to the controllers to make it compatible.

The problem I am encountering is that fileupload is creating a 'Delete' button which goes to the link below:

The button's property is data-type="DELETE"

Basically what this should do is initiate a DELETE in the 'file' folder to remove "SAMPLE PICTURE.JPG"

I have tried this with a plain PHP setup and it is working fine.

What php file is answering the request in that case?
 

Looking at the error returned, cakephp is routing the link to the controller:

Missing Method in AppController

Error: The action webroot is not defined in controller AppController

Error: Create AppController::webroot() in file: app\Controller\AppController.php.

<?php  class AppController extends AppController {      	public function webroot() {    	}    }

Read the above as "404 Not found". 

Is it possible to make cakephp exempt the MVC for that particular link?

That's not what you want to do. Cake does not "hijack" urls that map to files in the webroot. If you've put a file in the webroot for handling the deleting of uploaded files, you need only point at it (i.e. the url needs to explicitly point at the same file for "a plain PHP setup" for the same processing to occur).

hth,

AD

--
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+unsubscribe@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.

Saturday, December 21, 2013

Re: CakePHP Newbie Questions

No doubt you've seen http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html

With this, you set up the Auth component to tell it how you're doing your Auth, and what the loginAction should be.  Once a user request comes in for a page that requires authentication, and if they're not Authentication, the component will redirect the user to the login action, get them logged in, and then redirect them to the original page they were trying to get to.  Of course, you're free to directly display your login action as well.

As mentioned before, Controllers don't need a Model, but will use convention to determine a model to use, if one is not supplied.  If you want a controller with no Models, use public $uses = false or public $uses = array(), as described here : http://book.cakephp.org/2.0/en/controllers.html#Controller::$uses

When you set up the Auth component, you'll also set up a model that is used for that authentication.  Usually it's a User model, with a username and password.  To access any fields in the auth model for the current authentication session, from the controller, use $this->Auth->user();  i.e. $this->Auth->user('username') will give you the user name of the currently logged in user. As seen here: http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#accessing-the-logged-in-user

I hope that answers your questions.

Regards
Reuben Helms

On Wednesday, 18 December 2013 03:21:50 UTC+10, Nick Harper wrote:
Hi,

I have recently started to learn CakePHP after just being used to coding from scratch.

I have installed a couple of plugins but the issue I have is linking them together, for example if I have a login script then how on earth do I just show the login page for example?

Does every Controller need to have a mysql assigned to it?

I have been through the blog tutorial but so far it just feels really restrictive compared to just coding from scratch but what really appeals is the plugins / helpers but I am just struggling with basic things like echoing the username they are logged in with when logged in etc.


--
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+unsubscribe@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: Looking for Help with Cakephp basics .. aka looking for a mentor

When I get back from my Christmas break, I'll have a look at a bit of code I usually stick in my AppController or AppModel (it's been that long, I cant quite remember where it sits), but basically, it uses convention to recognise a file upload, and will save the file contents to a database field.

For a Search tool, I'd recommend Lucene for indexing, and do local HTTP calls to get the search results.  I think Zend may even have a PHP lib to assist with Lucene, but at some point, you're going to have to get your hands dirty and actually set it up (it's Java based).  Actually, scratch that.. use Apache SOLR. It sits on top of Lucene, and provides the HTTP API.

Pagination is pretty simple. The Pagination component assist with defining the query, and getting the data.  The Pagination Helper assist with display of numbers and first, last, next, previous options.  I usually do an element to roll all those things into one call from the view.

Breadcrumbs are easy if a page is only available from one menu option.  They can get a bit trickier if a page can exist at two menu options, and you don't know which one ( I give you the mess that is Joomla's ItemID, used to identify a page displayed on a particular menu).

Anyway, you have a good Christmas, too.


On Sat, Dec 21, 2013 at 2:12 AM, Silver Troy <educatedrisk@gmail.com> wrote:
Hello Reuben,
  I want to thank you for that well thought reply, the answers and pointers you have given me.  I really do try and find the answers through google, the cook book, youtube and irc.  I just know that sometimes people can answer your question in a couple minutes that will save you hours of wasting your time.
I have read through the cook book a few times already and though it does give some basic examples it lacks answering common problems.

I have done the blog tutorial, expanded it with Andrew Perkins youtube tutorials to add in authorization.  I have built a basic administration section and a user account section with routing (that took way too much time messing around).  I have been able to create form dropdowns that get populated from other models, and I recognize the data['User']['purchased']['year']  from the examples.  I have built a number of different sections like products, manufacturers, dealers, deals, users using the basic scaffolding. 

I do need to get into the Category Tree Structure, which I have looked into a number of examples, going to need to implement Pagination, Breadcrumbs and a proper Search tool (that works with multi-word searches).  Not to mention uploading multiple images for a product with a main (or default) image set.  I have been looking into using a plugin to do the image upload but that has been challenging to get one installed and working properly.

The next time I post .. I will keep it to one problem and try and layout what I have done.

Have a good Christmas.


--
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 a topic in the Google Groups "CakePHP" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cake-php/OsnN5POIi3w/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cake-php+unsubscribe@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.

--
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+unsubscribe@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.

Initiating a 'DELETE' or 'POST' in a folder inside webroot

Hi,

I am using the fileupload jquery library. I was able to get everything working and migrated some functions to the controllers to make it compatible.

The problem I am encountering is that fileupload is creating a 'Delete' button which goes to the link below:
http://localhost/homsite/app/webroot/?file=SAMPLE%PICTURE.JPG

The button's property is data-type="DELETE"

Basically what this should do is initiate a DELETE in the 'file' folder to remove "SAMPLE PICTURE.JPG"

I have tried this with a plain PHP setup and it is working fine.

Looking at the error returned, cakephp is routing the link to the controller:

Missing Method in AppController

Error: The action webroot is not defined in controller AppController

Error: Create AppController::webroot() in file: app\Controller\AppController.php.

<?php  class AppController extends AppController {      	public function webroot() {    	}    }


Is it possible to make cakephp exempt the MVC for that particular link?

Thank you!






--
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+unsubscribe@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.

Friday, December 20, 2013

content type application/json

Hello.  I have been working with CakePHP in some capacity for about two years.  I have never contributed to the project, and I was considering doing so, but I thought I would post first, as I am apprehensive about whether my contribution is something useful to everyone, or if it is specific to my use case.

To be clear, I currently am using Cake for rendering JSON only into an angularJS frontend.  By default, my requests are content-type application/json.  PHP in general does not like this very much, and Cake no more so.  I propose to modify the CakeRequest Class to check for content-type == application/json before doing anything else, and if that is the case, then reading the contents of php://input into $request->data.  For me, this solves many problems:

1.  POST data is always contained in $controller->request->data regardless of whether request method is POST, PUT, DELETE, etc.
2.  For PUT in particular, Cake currently will not route application/json requestsin the case that it is to be overridden by the POST value _method.
3.  POST data is ALWAYS contained in $controller->request->data.

As I said, for me this is a good solution.  I was going to implement it, and just make a merge request (not much code), but my change breaks some of the existing test cases, namely Network/CakeRequestTest/testPutParsingJSON.  In my opinion, the test should be changed, because it does not represent a real world situation (Can you actually make an honest-to-god PUT request to PHP?).  I would think that "faking" a PUT request with POST is more common.  Can anyone provide me with some feedback on this, or an answer to why it hasn't been done already?  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+unsubscribe@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: the Form with method GET generate incorrent URL

You could look into https://github.com/CakeDC/search#post-redirect-get-concept

"PRG Component
The Prg component implements the PRG pattern so you can use it separately from search tasks when you need it.
The component maintains passed and named parameters or query string variables that come as POST parameters and transform it to the named during redirect, and sets Controller::data back if the GET method was used during component call."


Andras Kende



On Dec 19, 2013, at 6:12 AM, Mukesh Ashtekar <ashtekarmukesh@gmail.com> wrote:

> Have You Found solution for this ??? I am also looking for this...
>
> On Monday, November 1, 2010 8:53:36 AM UTC+5:30, DANNY wrote:
> Hi All:
> I look the tutorial that Pagination for custom queries
> (http://bakery.cakephp.org/articles/shird10/2010/08/29/pagination-for-
> custom-queries)
>
> I can search the data by use URL (example.com/forums/viewtopic/x/y/
> page:2)
> But I want to use Form(method is GET) to generate the url
>
> <!-- ------search------ -->
> <?php echo $this->Form-
> >create('Order',array('action'=>'index','type'=>'get'));?>
> <?php echo $this->Form->input('x'); ?>
> <?php echo $this->Form->input('y'); ?>
> <?php echo $this->Form->end(__('submit', true));?>
> <!-- ------search------ -->
>
> I press the summit button , I get the url is :
> example.com/forums/viewtopic?x=AAAAAAA&y=BBBBBB
>
> not example.com/forums/viewtopic/x/y/page:2
> How to create the above Url by Form and method is GET
>
> 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+unsubscribe@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.

--
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+unsubscribe@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: CakePHP Newbie Questions

Hey Nick,
 I know your pain .. I suggest watching these videos  http://www.youtube.com/playlist?list=PL20D663BEC6319E36
they will really help explain and walk you through setting up a login / logout

Hopefully that helps you and get you moving on your application.

Cheers




On Tuesday, December 17, 2013 12:21:50 PM UTC-5, Nick Harper wrote:
Hi,

I have recently started to learn CakePHP after just being used to coding from scratch.

I have installed a couple of plugins but the issue I have is linking them together, for example if I have a login script then how on earth do I just show the login page for example?

Does every Controller need to have a mysql assigned to it?

I have been through the blog tutorial but so far it just feels really restrictive compared to just coding from scratch but what really appeals is the plugins / helpers but I am just struggling with basic things like echoing the username they are logged in with when logged in etc.


--
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+unsubscribe@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: Looking for Help with Cakephp basics .. aka looking for a mentor

Hello Reuben,
  I want to thank you for that well thought reply, the answers and pointers you have given me.  I really do try and find the answers through google, the cook book, youtube and irc.  I just know that sometimes people can answer your question in a couple minutes that will save you hours of wasting your time.
I have read through the cook book a few times already and though it does give some basic examples it lacks answering common problems.

I have done the blog tutorial, expanded it with Andrew Perkins youtube tutorials to add in authorization.  I have built a basic administration section and a user account section with routing (that took way too much time messing around).  I have been able to create form dropdowns that get populated from other models, and I recognize the data['User']['purchased']['year']  from the examples.  I have built a number of different sections like products, manufacturers, dealers, deals, users using the basic scaffolding. 

I do need to get into the Category Tree Structure, which I have looked into a number of examples, going to need to implement Pagination, Breadcrumbs and a proper Search tool (that works with multi-word searches).  Not to mention uploading multiple images for a product with a main (or default) image set.  I have been looking into using a plugin to do the image upload but that has been challenging to get one installed and working properly.

The next time I post .. I will keep it to one problem and try and layout what I have done.

Have a good Christmas.


--
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+unsubscribe@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.

Cake DC Sluggable Utility Question

I have the Sluggable Utility up and running and creating the slugs no issue.

 

Where I am stuck is I am trying to get the 'scope' => array() but working but just getting errors.

 

Maybe I misunderstood this key. I want slugs to be unique to the specific. So every user can have "my-first-post" slug which is unique to user_id

The slug is used in conjunction with the user:slug which is unique so in this case the post:slug only has to be unique to the user and not the entire site:

Example:

site/bob/post/my-first-post

 

site/george/post/my-first-post

 

site/carol/post/my-first-post

 

 

/**

* Default settings

*

* label                  - The field used to generate the slug from

* slug                   - The field to store the slug in

* scope                               - conditions for the find query to check if the slug already exists

* separator                        - the character used to separate the words in the slug

* length                              - the maximum length of the slug

* unique                             - check if the slug is unique

* update                             - update the slug or not

* trigger                              - defines a property in the model that has to be true to generate the slug

*

* Note that trigger will temporary bypass update and act like update is set to true.

*

* @var array

*/

 

So in ny model:

public  $actsAs = array(

                                'Sluggable.Sluggable' => array(

                                    'label' => 'title',

                                    'slug' => 'slug',

                                    'separator' => '-',

                                    'scope' => array('user_id' => '???')

                                ));

 

I tried passing the raw $this->data to get user_id but errors.

Tried AuthComponent::user('id'), errors.

 

Any ideas how I can accomplish this?

 

Thanks,

Dave

Thursday, December 19, 2013

Re: Cakephp 2.x ajax edit not working in Firefox and Opera

im also having this kind of problem.
does anyone know what's wrong with this one?



On Friday, September 14, 2012 6:23:05 AM UTC+8, incognito wrote:
Hi, 

I am basically trying to create an ajax edit form. 
This is the edit link code 

<?= $this->Js->link('Edit', 
      array('controller' => 'employees', 'action' => 'personal_details_edit',$employee['Employee']['id']), 
      array( 
         'update' => '#personal_details_update', 
         'evalScripts' => true, 
        'before' => $this->Js->get('#busy-indicator')->effect('fadeIn', array('buffer' => false)), 
     'complete' => $this->Js->get('#busy-indicator')->effect('fadeOut', array('buffer' => false)), 
      ) 
   ); 
 echo $this->Js->writeBuffer();   
?> 

And this is the ajax form code which gets loaded after clicking the above edit link. 

<? 
//serialize the form element to submit 
  
    $data = $this->Js->get('#employee_personal_edit')->serializeForm( 
                                                array( 
                                                'isForm' => true, 
                                                'inline' => true) 
                                            ); 
  
    // Submit the serialize data on submit click 
    $this->Js->get('#employee_personal_edit')->event( 
          'submit', 
          $this->Js->request( 
            array('action' => 'personal_details_edit'), 
            array( 
                    'update' => '#personal_details_update', // element to update 
                                             // after form submission 
                    'data' => $data, 
                    'async' => true, 
                    'dataExpression'=>true, 
                    'method' => 'POST', 
            
                  
                ) 
            ) 
        ); 
 echo $this->Js->writeBuffer(); 
?> 


The form submit is working in Chrome, IE, Safari but not working in Firefox and Opera.When I click form submit in Firefox nothing happens(no XMLHTTPRequest is being sent). 

If i access the form link directly(without loading via ajax edit link)its working normally in Firefox. 

How to fix it?Any help is appreciated. :)  

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@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.