cakephp-1.3

How to limit data to users who own it without limiting admin users in CakePHP?

我的梦境 提交于 2019-11-29 07:57:06
Currently I am writing an application where I have multiple users. They have data that should only be visible to them and not the other authenticated users in the system. I also have administrators who manage the system and have access to all of the information. What is the best way to limit users to their data without limiting admin users? Currently I am using a callback to limit the queries by user, but the admin will get the same limits. So I need to know a better way to do it. More importantly, the right way to do it. For example, I want the standard user to be able to see their user

Modify session cookie expiry and session timeout for a CakePHP session

流过昼夜 提交于 2019-11-29 07:20:53
I'm struggling to accomplish the following: Alter the user's session cookie expiry date based on the user's type. I have a CakePHP web application wherein I have created my authentication component (instead of CakePHP's Auth) using CakePHP sessions. I've configured CakePHP to handle sessions using the database. Here are the relevant configuration settings that I have in my config.php: Configure::write('Session.save', 'database'); Configure::write('Session.timeout', '36'); Configure::write('Security.level', 'medium'); How do I extend the session cookie expiry date AND update the value in the

cakephp see the compiled SQL Query before execution

江枫思渺然 提交于 2019-11-29 01:36:06
My query gets the timeout error on each run. Its a pagination with joins. I want to debug the SQL, but since I get a timeout, I can't see it. How can I see the compiled SQL Query before execution? Some cake code: $this -> paginate = array( 'limit' => '16', 'joins' => array( array( 'table' => 'products', 'alias' => 'Product', 'type' => 'LEFT', 'conditions' => array('ProductModel.id = Product.product_model_id') )), 'fields' => array( 'COUNT(Product.product_model_id) as Counter', 'ProductModel.name' ), 'conditions' => array( 'ProductModel.category_id' => $category_id, ), 'group' => array(

cakephp one form, multiple models, not displaying one model's validation messages

安稳与你 提交于 2019-11-29 01:08:34
问题 I have a registration form and I am creating a record in both User and Identity tables (a user hasMany identities) the form looks like this <?php echo $this->Form->create('User');?> <fieldset> <legend><?php __('Register'); ?></legend> <?php echo $this->Form->input('Identity.name'); echo $this->Form->input('Identity.surname'); echo $this->Form->input('User.username'); echo $this->Form->input('User.pass'); echo $this->Form->input('User.pass_confirm', array('type' => 'password')); echo $this-

Submitting current timestamp in CakePHP

佐手、 提交于 2019-11-28 23:23:33
What is the method to submit a current timestamp directly on an INSERT or an UPDATE ? If I were running regular SQL, I would use the function NOW() for the specific SQL field on submission. How would I do that with CakePHP? $this->Model->save($this->data) webbiedave In CakePHP, you can include the NOW() function unescaped by using DboSource::expression $this->data['SomeModel']['your_datetime_field'] = DboSource::expression('NOW()'); $this->Model->save($this->data); This is the preferred way of including MySQL functions in your saves. http://api.cakephp.org/2.3/class-DboSource.html#_expression

CakePHP - problem with HABTM paginate query

别说谁变了你拦得住时间么 提交于 2019-11-28 20:57:45
Tables restaurants cuisines cuisines_restaurants Both restaurant and cuisine model are set up to HABTM each other. I'm trying to get a paginated list of restaurants where Cuisine.name = 'italian' (example), but keep getting this error: 1054: Unknown column 'Cuisine.name' in 'where clause' Actual query it's building: SELECT `Restaurant`.`id`, `Restaurant`.`type` ..... `Restaurant`.`modified`, `Restaurant`.`user_id`, `User`.`display_name`, `User`.`username`, `User`.`id`, `City`.`id`,`City`.`lat` ..... FROM `restaurants` AS `Restaurant` LEFT JOIN `users` AS `User` ON (`Restaurant`.`user_id` =

Routing: 'admin' => true vs 'prefix' => 'admin in CakePHP

徘徊边缘 提交于 2019-11-28 17:06:39
Hi I'm setting up admin routing in CakePHP. This is my current route: Router::connect('/admin/:controller/:action/*', array('admin' => true, 'prefix' => 'admin', 'controller' => 'pages', 'action' => 'display', 'home')); It works fine, but I don't understand what the difference between 'admin' => true, and 'prefix' => 'admin' is. When I omitted 'prefix' => 'admin' , the router wouldn't use admin_index and would instead just use index . So what's the point of 'admin' => true ? By setting 'prefix' => 'admin' you are telling CakePHP that you want to use a prefix of admin for that route; basically

Error: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual

ぐ巨炮叔叔 提交于 2019-11-28 13:14:53
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 '@g.com, 'User'.'phone' = 87665r5, 'User'.'address' = 23lsdhf, 'User'.'location' ' at line 1 SQL Query: UPDATE 'cake'.'users' AS 'User' SET 'User'.'username' = paul, 'User'.'password' = eben, 'User'.'email' = paul@g.com, 'User'.'phone' = 87665r5, 'User'.'address' = 23lsdhf, 'User'.'location' = lskjaflasi, 'User'.'pincode' = 867567 WHERE 'User'.'id' = 1 My code is if($this->request->data) {$User=$this

Select All Events with Event->Schedule->Date between start and end dates in CakePHP

♀尐吖头ヾ 提交于 2019-11-28 11:21:17
问题 Trying to figure out how to build a query in CakePHP where I can select all Events that are between X and Y dates (user-entered dates). The problem lies in that the Event doesn't have the dates in it's table. Event hasMany Schedule Schedule belongsTo Event Schedule hasMany Date Date belongsTo Schedule Events table : details of the event - name, location, description...etc Schedules table : start and end date with repeat options Dates table : the actual dates of the event created from the data

Cakephp SMTP emails syntax error

淺唱寂寞╮ 提交于 2019-11-28 08:57:09
问题 I've got a problem with email sending in cake. My method looks like this: $this->Email->smtpOptions = array( 'port'=>'465', 'timeout'=>'30', 'auth' => true, 'host' => 'ssl://smtp.gmail.com', 'username'=>'mymail@gmail.com', 'password'=>'mypass', ); $this->Email->from = "admin@localhost"; $this->Email->to = "my_test_mail@centrum.cz"; $this->Email->subject = "Test"; $this->Email->sendAs = "text"; $this->Email->delivery = 'smtp'; $this->Email->send('Hello message body!'); But when I try to send