Example #1
0
 public function action_editfields()
 {
     $groupId = intval($this->request->param('id'));
     $paramName = $this->request->param('param');
     $group = new Model_Material('groups');
     if (isset($_POST['delete_fields'])) {
         $result = $group->deleteParams($_POST['pid']);
     }
     if (isset($_POST['sort_fields']) && isset($_POST['params'])) {
         $group->sortParams($_POST['params'], $groupId);
         Controller::redirect('/admin/materials/' . $groupId . '/fields');
     }
     if (isset($_POST['saveParam'])) {
         $group->updateParam($_POST, $paramName, $groupId);
         Controller::redirect('/admin/materials/' . $groupId . '/fields');
     }
     if (isset($_POST['saveExcelSettings'])) {
         $group->updateExcelSettings($_POST, $groupId);
     }
     $groupData = $group->getGroup($groupId);
     $this->data['groups'] = $group->getTree();
     $this->data['groupParams'] = $group->getParams($groupId);
     $base = new Model_Base();
     $options = $base->getOptions();
     if (!$paramName) {
         $params = View::factory('admin/admParams', array('data' => $this->data['groupParams'], 'user' => $this->user, 'group' => $groupData, 'options' => $options));
     } else {
         $param_data = $group->getField($paramName, $groupId);
         $params = View::factory('admin/admParam', array('data' => $param_data, 'user' => $this->user, 'group' => $groupData, 'options' => $options));
     }
     $this->template->content = View::factory('admin/admMaterials', array('data' => $this->data, 'user' => $this->user, 'params' => $params));
 }