cakephp-2.0

cakephp 2.0 how to update auth data?

前提是你 提交于 2019-12-02 18:25:15
when I update data in the User model, the Auth data is not updated. How can I "refresh" the data which is returned by $this->Auth->user() when I am updating user model ? and I don't want to use $this->Auth->login($data); after updating my user table I tried the following line. Its works well form me After modify the user data i written the following line $this->Session->write('Auth', $this->User->read(null, $this->Auth->User('id'))); Write the updated data to the Session eg: $this->Session->write('Auth.User', $data); Before CakePHP 2.x you can't do this in the model without break the framework

cakephp login page doesn't go anywhere

三世轮回 提交于 2019-12-02 16:18:13
问题 I have tried to set up a login page, but when I try to log in, even with a wrong username/password, cake redirects to the login page (the logout function redirects correctly). Even if I plug in the wrong info, I get no error flashes at all, I don't get it. Here is my controller code: class UsersController extends AppController { public $name='Users'; public $layout='pagelayout'; public $uses=array('User'); public function beforeFilter() { parent::beforeFilter(); $this->Auth->allow('add',

Cakephp add function if id exists edit else create

不羁岁月 提交于 2019-12-02 15:58:55
问题 I'm using cakephp 2 in my controller add function, I want to edit the data if the id exists, if not exists create. This is my code in add function: public function add () { if(!$this->request->data){ throw new NotFoundException(); } $googleCategory = $this->request->data; foreach ($googleCategory as $key => $value) { if(empty($value['category'])){ unset($value); } $conditions = array ( 'AccountShopMeta.shop_id' => $value['shop_id'], 'AccountShopMeta.name' => $value['category'],

CakePHP re-populate list box

江枫思渺然 提交于 2019-12-02 13:33:06
I have a question about cakePHP. I create two drop down lists in my view. When the user changes the value in one list, I want the second to change. Currently, I have this working like this: An on click event fires when the user selects from list box one. This fires a jQuery ajax function that calls a function from my controller. This is all working fine, but how do I re-render my control, asynchronously (or, view)? I i know I could just serialize the array to json and then recreate the control in javascript, but there seems like there should be a more "CakePHP" way. Isn't that what render is

cakephp login page doesn't go anywhere

风流意气都作罢 提交于 2019-12-02 12:42:06
I have tried to set up a login page, but when I try to log in, even with a wrong username/password, cake redirects to the login page (the logout function redirects correctly). Even if I plug in the wrong info, I get no error flashes at all, I don't get it. Here is my controller code: class UsersController extends AppController { public $name='Users'; public $layout='pagelayout'; public $uses=array('User'); public function beforeFilter() { parent::beforeFilter(); $this->Auth->allow('add', 'logout', 'overview'); } public function login() { $this->set('title', 'Log in to your Gulf Shores 4 Less

Auth login with email or mobile Cakephp

*爱你&永不变心* 提交于 2019-12-02 12:18:57
I am working on cakephp 2.x.i have a table in my database name user and it has 4 fields id, email, password and mobileNo i have two fields in my login.ctp <?php echo $this->form->create(); echo $this->form->input('email'); echo $this->form->input('password'); echo $this->form->end('submit'); ?> what i want is i want to login the user from his mobileNo too(if he typed mobile number rather then email address) just like facebook has done ..he can either login with hi email address or mobileno .i dont want to create another input field.. i dont know how can i do this here is my code AppController

How to use “response” from any XMLHTTPREQUEST in CakePHP (2.5)

我的梦境 提交于 2019-12-02 11:45:39
问题 I got the action "pega" in controller Posts: public function pega($id = null) { $posts = $this->Post->findById($id); foreach($posts as $pok) { $foda = $pok['love']; } $this->set('foda', $foda); $this->set('_serialize', array('foda')); } In my layout I try to do a requestto catch the data from function "pega" and put inside tag html: <script> var xmlhttp = new XMLHttpRequest(); var url = "http://localhost:81/booklandia/posts/pega/<?php echo $post['Post']['id'];? >.json"; xmlhttp

CakePHP find not returning correctly - missing model name

☆樱花仙子☆ 提交于 2019-12-02 10:08:42
问题 After performing a find on a model I would expect the result to be of the format Array ( [0] => Array ( [ModelName] => Array ( [id] => 83 [field1] => value1 [field2] => value2 [field3] => value3 ) ) ) However, what I appear to be getting is Array ( [0] => Array ( [0] => Array ( [id] => 83 [field1] => value1 [field2] => value2 [field3] => value3 ) ) ) Note the missing model name. I've only been getting this problem since migrating across to what appears to be a very poorly configured VPS that

Avoid recording errors and debug logs on CakePHP 2

删除回忆录丶 提交于 2019-12-02 09:58:42
问题 I am using an small hosting with only 200Mb of space and the error.log and debug.log files placed in "App/tmp/logs" are increasing in size very fast. Now their size is around 120Mb. I am using a cron job every 2 minutes and it could be the cause of it. I would like to disable the creation of both logs. How can I do it? 回答1: The actual solution is to fix the errors and remove the debugging statements so that nothing would be written in the logs. To answer the question literally, you can

cakephp plugin model/controller cache issue with main model/controller

北慕城南 提交于 2019-12-02 09:48:49
I have a plugin with user model, profile model and an user controller, in this user model is associated with profile model. In my main model folder (under app), I have user model and user controller(here I have not associated with profile). Sometimes I'm getting errors saying that user model is not associated with profile model. Also sometimes I'm getting the error - "missing action logout in users controller". I have given the logout action in the app/controller/userscontroller but that method is not available in myplugin/usercontroller. Im using cakephp2.0.. How can I solve this issue ? How