Advertisement
fernandezekiel

Untitled

Feb 3rd, 2014
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.47 KB | None | 0 0
  1. class StudentController extends Controller
  2. {
  3.     //custom function
  4.     public function accessCriteria()
  5.     {
  6.         $criteria = new CDbCriteria();
  7.         if (!Yii::app()->user->isSuperuser) {
  8.             $criteria->condition = 'branch_id=:bid';
  9.             $criteria->params = [':bid'=>Yii::app()->user->id];
  10.         }
  11.        
  12.         return $criteria;
  13.     }
  14.  
  15.     //in update method:
  16.     public function actionUpdate($id) {
  17.         $student = Student::model()->findByPk($id, $this->accessCriteria());
  18.         // then your code
  19.     }
  20.  
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement