cakephp-2.0

Password Confirm Validation CakePHP

故事扮演 提交于 2019-12-05 17:20:36
I have searched far and wide, tried every trick in the book, but I still can't get my CakePHP application to perform simple Password Confirm validation. I've tried creating a custom validation rule like this: 'passwordequal' => array('rule' => 'checkpasswords' , 'message' => 'Passwords Do Not Match') Then defined 'checkpasswords' like this: public function checkpasswords(){ if(strcmp($this->data['User']['new_password'],$this->data['User']['confirm_password']) == 0 ) { return true; } return false; } 'new_password' and 'confirm_password' are the password input fields. This didn't work. Then I

How do I get a list of all functions inside a controller in cakephp

£可爱£侵袭症+ 提交于 2019-12-05 15:54:35
问题 I needed to select a controller in CakePHP 2.4 and display all the functions written in it. I found how to list controllers from this question & answer thread on Stack Overflow but what I need now is given a specific controller I need to get the list of all functions it contains. Here what i have done public function getControllerList() { $controllerClasses = App::objects('controller'); pr($controllerClasses); foreach($controllerClasses as $controller) { $actions = get_class_methods(

CakePHP Cache::clear does not work

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-05 11:34:57
I have a Cache Configuration in my bootstrap.php file as Cache::config('long', array( 'engine' => 'File', 'duration' => '+1 week', 'probability'=> 100, 'mask' => 0666, 'path' => CACHE . 'long' . DS, )); and i am trying to clear cache when a setting is edited. Below is my admin_edit function public function admin_edit($id = null) { if (!$this->Setting->exists($id)) { throw new NotFoundException(__('Invalid setting')); } if ($this->request->is('post') || $this->request->is('put')) { if ($this->Setting->save($this->request->data)) { $this->Session->setFlash(__('The setting has been saved'));

Cakephp Authcomponent session expire after using SSL unforce method

霸气de小男生 提交于 2019-12-05 11:22:43
Using SSL for 5 pages while during registration https://www.mysite.com/step1 https://www.mysite.com/step2 https://www.mysite.com/step3 - Auth component login https://www.mysite.com/step4 https://www.mysite.com/step5 After step 3 I am creating a Session of the user using Auth Component ( automatically make the user logged in by Auth component). But after step5 It will redirect to the following page http://www.mysite.com/welcome I am using SSL component unforced method to change HTTPS to HTTP . Every thing working fine but the problem is Once I reached the welcome page from step5(HTTPS) my Auth

Cakephp image -Can not determine the mimetype

社会主义新天地 提交于 2019-12-05 10:25:47
cakephp 2.3 I'm uploading an image and I have an error saying that: Can not determine the mimetype. Error: An Internal Error Has Occurred. On my Model this is a part of my $validation 'file_name' => array( 'uploadError' => array( 'rule' =>'uploadError', 'message' => 'Your image upload failed', 'allowEmpty' => FALSE, //'required' => false, //'last' => false, // Stop validation after this rule //'on' => 'create', // Limit validation to 'create' or 'update' operations ), 'mimeType' => array( 'rule' => array('mimeType', array('image/gif', 'image/png', 'image/jpg', 'image/jpeg')), 'message' =>

Authorization adapter was not found in cakePHP

↘锁芯ラ 提交于 2019-12-05 10:09:47
I'm trying to move my code from local to server when i try to login into the application Here is my AppController class AppController extends Controller{ /* Determines what logged-in users access to */ var $components = array('Auth','Session'); public function isAuthorized($user){ return true; } public function beforeFilter(){ $userdetails = array(); $this->Auth->autoRedirect = false; $this->Auth->loginAction = array('controller' => 'users', 'action' => 'login'); $this->Auth->loginRedirect = array('controller' => 'matches', 'action' => 'index'); $this->Auth->authorize = 'controller'; $this-

Run plugin's shell in cakephp 2.0

北城以北 提交于 2019-12-05 08:44:59
I have created a new CakePHP 2.0 app and want to run a plugin's shell. <?php // app\Plugin\Tmaker\Vendors\Shells\TmakerShell.php class TmakerShell extends Shell { } However, I can't see it when running Console/cake from the command-line. Please advise my what I have missed? According to the latest documentation , the path for shells has changed to app/Console/Command/ . Move your shell to the following location: app/Plugin/Tmaker/Console/Command/TmakerShell.php (not sure if plugin directory names are camel-cased in CakePHP 2.0, but it seems to work either way.) <?php class TmakerShell extends

Calling AppModel function in AppController for cakephp

最后都变了- 提交于 2019-12-05 08:18:01
I have a function that I want all of my controllers to be able to use, so I have defined it in AppController. Now part of what this function will do has no business being in a controller and so it should be in a model, but since this is a universal operation, it only seems correct that it be in AppModel. My function looks as followed: class AppController extends Controller { public function i_need_this_everywhere ($term) { // do some stuff // this is the line that is an issue // it seems like this should be simple and work, but no variation of this is working $value = $this->App->get_some_cool

Adding conditions to Containable in CakePHP

六月ゝ 毕业季﹏ 提交于 2019-12-05 06:34:54
Previously I was relying on recursive, but I didn't get solution for some, then I found that Containable works fine for these. I am developing a movie review website. In that I need to show the list of movies which is related to a particular Genre. I have this below code: //example $genre = "drama"; $options = array( 'contain' => array( 'Movie', 'MoveiGenre.Genre' => array( 'conditions' => array('MovieGenre.Genre.name = "'.$genre.'"') ), 'MovieGenre.Genre.name' ), 'recursive' => 2, 'limit' => 10 ); $this->paginate = $options; $this->set('movies',$this->paginate()); The real problem starts here

Cakephp REST API remove the necessity of .format

感情迁移 提交于 2019-12-05 02:43:18
I am working on creating a REST api that will only get and return JSON data. I'm following the cake guide and my default routes are like this: GET /recipes.format GET /recipes/123.format POST /recipes.format PUT /recipes/123.format DELETE /recipes/123.format POST /recipes/123.format However, I really dislike the necessity of using the ".format" (".json" in my case) since I will only ever be accepting json. I feel like there has to be a way to remove this necessity. I could use .htaccess to rewrite URLS, but I feel like there must be a way to do this in a cake setting / config file somewhere.