cakephp

How to "Validate" Human Names in CakePHP?

I have a PHP script that is supposed to check for "valid" human names, but recently cracked against a name with a space, so we added spaces to our validator. Rather than doing this, is there a way to add a blacklist to CakePHP's validator to block all "invalid" characters, rather than allowing "valid" ones? NOTE: I know how to do this...

How to get Ajax Request Progress ?

  I am developing a project which is built in CakePHP and using jQuery in it. I have a script which need to be called by an ajax request. This request do many manipulation in database and takes too much time. Between the execution it is writing its status in a seperate file so i can see the status of script execution. Every time it open ...

cakephp - find conditions over multiple models

Hi, I am trying to do a find with conditions in two models. Is this possible ? $offices = $this->User->Org->find('first', array( 'conditions' => array( "or" => array( 'Org.website LIKE' => $match, 'Domain.domain' => $match ) ) )); ...

where to define constants in cakephp

In which file should I define application-wide constants that are specific to my cakephp app? ...

How can a PHP REST API receive PUTted data?

I'm writing an API and want to follow the REST approach. As I understand it, if I want to let API users update specific records a PUT http://server/specific_resource type request should be supported. Of course, they're not doing a GET and they'll need to pass along the new data and my question is how to do this (in my specific case only ...

Paypal checkout and mass payment integration with cakephp

I'm dealing with a problem when starting with a project evolving cakephp and paypal. I never used paypal in my life and I have a lot of questions about it. I want to know if any of you have ever seen a really starter tutorial to paypal development and a good cakephp plugin to perform this. The project consists of a payment system by cre...

CakePHP virtual field that is a sum of three other virtual fields?

I have a virtual field in CakePHP that needs to be a SUM of three very disparate SQL queries in my User model. I'm trying to accomplish this by having a virtual field that is a sum of 3 other virtual fields. var $virtualFields = array ( 'field_one' => 'select coalesce(sum(coalesce(t_a.field, 0)), 0)*10 as field_one from t_a joi...

Cakephp - tree structures generatetreelist blank space spacer

Hi, I need to have blank spaces as my spacers in a tree structure. Here is my code at the moment $sectors = $this->User->Sector->generatetreelist(null, null, null, '__'); $this->Form->input('Sector.user_id', array('options' => $sectors)); I tried nsp and also the escaped version. Any Idea ? Thanks, Alex ...

while validating in cakephp, what 'validate'=>'first' does?

I have written in my code like this... $this->User->saveAll($this->data, array('validate'=>'first')); $this->User->saveAll($this->data, array('validate'=>false)); 'validate'=>false will not check for validations in model. But if I replace false with first, then what will it do? Thanks. ...

CakePHP model->save(): save all but some excluded fields

Hello everybody. I want to save all but some excluded fields. I know that I can do it this way $this->Blah->save($this->data,false,$fieldList) Where $fieldList contains all the data fields of the table but these I don't want to get saved. I have some tables that have maaany data fields, and I don't want to write the whole list from sc...

Containable fails to JOIN in belongsTo relationships when 'fields' are used in CakePHP 1.3.4

(CakePHP Version 1.3.4) I have the following association between a Contact model with Account and Test models: class Contact extends AppModel { var $name = 'Contact'; var $actsAs = array('Containable'); var $hasMany = array( 'Test' => array( 'className' => 'Test', 'foreignKey' => 'contact_i...

Create the website first or set up Jquery on Cakephp?

I have set up Cakephp with admin login, but I do not have a page design. Now what? Do I have the site designed by a web-designer, or will this conflict with the person that is writing my fresh Jquery code. What about CSS? Is the Jquery developer going to know how to attach them? What comes first, the horse or carriage? Which ones th...

To get Analytics data and show on page what's the most popular items, should the code belong to Model, Controller, or View?

Suppose there is a call to get Analytics data from a third party or through our cache data on a server, for the "most popular items", and we show these items' names on all of our pages, should we put this code in Model, Controller, or View (Helper) component? Maybe it is not strictly Model, because it is not directly in our data store. ...

Cakephp Security

I am new to Security of Web apps. I am developing an application in Cakephp and one of my friends told me about the Cross-site request forgery (CSRF) and cross-site scripting (XSS) attacks etc. not sure how many more are there. I need some help in understanding how to make Cakephp defend my web app against these. we are low budget and w...

CakePHP Session keeps getting reset

I'm setting a Session variable with an ajax call. I've tried both by using the helper and by using the straight PHP $_SESSION syntax. For some reason, whenever I reload the page, all SESSION data is gone. What is annoying about this, is that it happens sporadically. I thought at first, it had to do with the browser I was using, but it ...

Multi Delete using checkbox

I am learning Cakephp and I've been trying to delete multiple (checked) record using checkbox, but still not success. here's my jQuery : var ids = []; $(':checkbox:checked').each(function(index){ ids[index] = $(this).val();; alert(ids[index]); }); //alert(ids); var formData = $(this).parents('form').serializ...

CakePHP form helper problem with date for editing

I'm quite newbie in CakePHP, I've tried to create a form with form helper on a date field echo $this->Form->input('Item.date'); yes, works fine (I'm using CakePHP v1.3.3) for input/add new record but when I try using it on edit page it does nothing. here's the code echo $this->Form->input('Item.date', array("value"=>$rs['Item']['date...

Weird CakePHP (1.3) Pagination component behaviour

Hi, I have a users list page where the result can be modified by using gender, city and country selects (dropdowns), and it's working perfectly fine. As we have a lot of users I need to put a pagination as well, and here comes the "weird" part (I am sure it's not weird but I just cannot figure out where the problem comes from): when I se...

cakephp find all posts that have comments

I created a simple blog that has posts and comments. I want to find all the posts that have at least one comment and also find all the posts with no comments. Is there a cakephp way to do this? I.E. maybe something like $this->Post->find('all', ???); I ended up writing my own query, the example below finds all the posts with at least ...

CakePHP: Accessing session data from within a controller

Hi, I have an edit action in the users controller. What I want to do is redirect anyone to a different action if their Auth.User.id does not equal the id of the user they are trying to edit. I can access variables in my views like this: if($session->read('Auth.User.id') != $id){ but this doesn't work in my controller. Getting: Und...