Ejemplo n.º 1
0
 public function before()
 {
     if ($this->request->action() == 'edit') {
         $id = (int) $this->request->param('id');
         $this->field = DataSource_Hybrid_Field_Factory::get_field($id);
         if (empty($this->field)) {
             throw new HTTP_Exception_404('Field ID :id not found', array(':id' => $id));
         }
         $ds = $this->section($this->field->ds_id);
         if ($this->field->has_access_edit()) {
             $this->allowed_actions[] = 'edit';
         }
     }
     if ($this->request->action() == 'add') {
         $ds_id = (int) $this->request->param('id');
         $ds = $this->section($ds_id);
         if ($ds->has_access('field.create')) {
             $this->allowed_actions[] = 'add';
         }
     }
     parent::before();
     if (!empty($ds)) {
         $this->template_js_params['DS_ID'] = $ds->id();
     }
 }
Ejemplo n.º 2
0
 protected function _get_field()
 {
     $field_id = $this->param('id', NULL, TRUE);
     $field = DataSource_Hybrid_Field_Factory::get_field($field_id);
     if ($field === NULL) {
         throw HTTP_API_Exception::factory(API::ERROR_UNKNOWN, 'Field not found!');
     }
     return $field;
 }