示例#1
0
 /**
  * DEPENDS on app_model for translateFieldNames and getFieldNames
  * DEPENDS on that you dont change default model and/or controller name
  * gets translated tablefields from current model
  */
 function getHeaders()
 {
     if (!isset($this->params['requested'])) {
         return;
     }
     $modelName = Inflector::Singularize($this->name);
     return $this->{$modelName}->translateFieldNames($this->{$modelName}->removeUnsetFields($this->{$modelName}->getFieldNames()));
 }
 public function _check_access($modelName = null)
 {
     $this->loadModel('User');
     $this->User->recursive = 0;
     $userAccess = $this->User->find('first', array('conditions' => array('User.id' => $this->Session->read('User.id')), 'fields' => array('User.user_access')));
     $newData = json_decode($userAccess['User']['user_access'], true);
     if (!$newData) {
         return true;
     } else {
         foreach ($newData['user_access'] as $m) {
             $model = array_keys($m);
             if (Inflector::Singularize(Inflector::Classify($model[0])) == $modelName) {
                 if ($m[$model[0]]['allow'] == true) {
                     return true;
                 } else {
                     return false;
                 }
             }
         }
     }
 }