|
@@ -126,6 +126,24 @@ class Channel extends Backend
|
|
|
$this->model->validate($validate);
|
|
|
}
|
|
|
$nameArr = array_filter(explode("\n", str_replace("\r\n", "\n", $params['name'])));
|
|
|
+
|
|
|
+ // 获取上级是否为期刊,如是期刊则存入期刊id
|
|
|
+ if ($params['channel_type'] == 'issues' || $params['channel_type'] == 'volume') {
|
|
|
+ $parent_channel = \app\admin\model\cms\Channel::where(['id' => $params['parent_id']])->find();
|
|
|
+ if ($params['channel_type'] == 'issues') {
|
|
|
+ if ($parent_channel) {
|
|
|
+ if ($parent_channel['channel_type'] == 'journal') {
|
|
|
+ $params['journal_id'] = $parent_channel['id'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ($params['channel_type'] == 'volume') {
|
|
|
+ if ($parent_channel) {
|
|
|
+ $params['journal_id'] = $parent_channel['journal_id'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if (count($nameArr) > 1) {
|
|
|
foreach ($nameArr as $index => $item) {
|
|
|
$itemArr = array_filter(explode('|', $item));
|
|
@@ -178,7 +196,61 @@ class Channel extends Backend
|
|
|
$this->view->assign('values', $channel);
|
|
|
$this->view->assign('childrenIds', $childrenIds);
|
|
|
$this->assignconfig('linkdata', $linkdata);
|
|
|
- return parent::edit($ids);
|
|
|
+
|
|
|
+ $row = $this->model->get($ids);
|
|
|
+ if (!$row) {
|
|
|
+ $this->error(__('No Results were found'));
|
|
|
+ }
|
|
|
+ $adminIds = $this->getDataLimitAdminIds();
|
|
|
+ if (is_array($adminIds) && !in_array($row[$this->dataLimitField], $adminIds)) {
|
|
|
+ $this->error(__('You have no permission'));
|
|
|
+ }
|
|
|
+ if (false === $this->request->isPost()) {
|
|
|
+ $this->view->assign('row', $row);
|
|
|
+ return $this->view->fetch();
|
|
|
+ }
|
|
|
+ $params = $this->request->post('row/a');
|
|
|
+ if (empty($params)) {
|
|
|
+ $this->error(__('Parameter %s can not be empty', ''));
|
|
|
+ }
|
|
|
+ $params = $this->preExcludeFields($params);
|
|
|
+ $result = false;
|
|
|
+ Db::startTrans();
|
|
|
+ try {
|
|
|
+ //是否采用模型验证
|
|
|
+ if ($this->modelValidate) {
|
|
|
+ $name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
|
|
|
+ $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
|
|
|
+ $row->validateFailException()->validate($validate);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取上级是否为期刊,如是期刊则存入期刊id
|
|
|
+ if ($params['channel_type'] == 'issues' || $params['channel_type'] == 'volume') {
|
|
|
+ $parent_channel = \app\admin\model\cms\Channel::where(['id' => $params['parent_id']])->find();
|
|
|
+ if ($params['channel_type'] == 'issues') {
|
|
|
+ if ($parent_channel) {
|
|
|
+ if ($parent_channel['channel_type'] == 'journal') {
|
|
|
+ $params['journal_id'] = $parent_channel['id'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ($params['channel_type'] == 'volume') {
|
|
|
+ if ($parent_channel) {
|
|
|
+ $params['journal_id'] = $parent_channel['journal_id'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $result = $row->allowField(true)->save($params);
|
|
|
+ Db::commit();
|
|
|
+ } catch (ValidateException|PDOException|Exception $e) {
|
|
|
+ Db::rollback();
|
|
|
+ $this->error($e->getMessage());
|
|
|
+ }
|
|
|
+ if (false === $result) {
|
|
|
+ $this->error(__('No rows were updated'));
|
|
|
+ }
|
|
|
+ $this->success();
|
|
|
}
|
|
|
|
|
|
/**
|