03.17 php saved
jben_mbp
Tags add more
auth and beforeFilter  
Note
jben_mbp did not leave a note
  1. <?php
  2.  
  3. class AppController extends Controller
  4. {
  5.     function beforeFilter()
  6.     {
  7.         // check a form has been submitted and that a user_id doesn't already exist
  8.         if (!empty($this->data) && !isset($this->data[$this->modelClass]['user_id']))
  9.         {
  10.             // add id of currently logged in user to data array
  11.             $this->data[$this->modelClass]['user_id'] = $this->Auth->user('id');
  12.         }
  13.     }
  14. }
  15.  
  16. ?>
Parsed in 0.021 seconds, using GeSHi 1.0.7.14

Modify this Paste