diff --git a/db/update9.5.1.sql b/db/update9.5.1.sql index 17036e2ff9..3f5b805613 100644 --- a/db/update9.5.1.sql +++ b/db/update9.5.1.sql @@ -98,3 +98,4 @@ CREATE TABLE `zt_score` ( ) ENGINE=MyISAM DEFAULT CHARSET=utf8; INSERT INTO `zt_cron` (`m`, `h`, `dom`, `mon`, `dow`, `command`, `remark`, `type`, `buildin`, `status`, `lastTime`) VALUES ('*/5', '*', '*', '*', '*', 'moduleName=webhook&methodName=asyncSend', '异步发送Webhook', 'zentao', 1, 'normal', '0000-00-00 00:00:00'); +ALTER TABLE `zt_projectstory` ADD `order` smallint(6) unsigned NOT NULL; diff --git a/module/file/control.php b/module/file/control.php index 6928e0002b..ee06434a15 100644 --- a/module/file/control.php +++ b/module/file/control.php @@ -485,6 +485,8 @@ class file extends control if(empty($file) or !file_exists($file->realPath)) return false; $mime = in_array($file->extension, $this->config->file->imageExtensions) ? "image/{$file->extension}" : $this->config->file->mimes['default']; + ob_end_clean(); + header("Content-type: $mime"); $handle = fopen($file->realPath, "r"); diff --git a/module/project/control.php b/module/project/control.php index e651b7e440..81e089333e 100644 --- a/module/project/control.php +++ b/module/project/control.php @@ -530,7 +530,7 @@ class project extends control * @access public * @return void */ - public function story($projectID = 0, $orderBy = '', $type = 'byModule', $param = 0, $recTotal = 0, $recPerPage = 50, $pageID = 1) + public function story($projectID = 0, $orderBy = 'order', $type = 'byModule', $param = 0, $recTotal = 0, $recPerPage = 50, $pageID = 1) { /* Load these models. */ $this->loadModel('story'); @@ -1991,6 +1991,32 @@ class project extends control } } + /** + * Story sort. + * + * @param int $projectID + * @access public + * @return void + */ + public function storySort($projectID) + { + $idList = explode(',', trim($this->post->storys, ',')); + $orderBy = $this->post->orderBy; + + $stories = $this->dao->select('story,`order`')->from(TABLE_PROJECTSTORY)->alias('t1') + ->leftJoin(TABLE_STORY)->alias('t2')->on('t1.story=t2.id') + ->where('t1.story')->in($idList) + ->andWhere('t1.project')->eq($projectID) + ->orderBy($orderBy) + ->fetchPairs('order', 'story'); + foreach($stories as $order => $id) + { + $newID = array_shift($idList); + if($id == $newID) continue; + $this->dao->update(TABLE_PROJECTSTORY)->set('`order`')->eq($order)->where('story')->eq($newID)->andWhere('project')->eq($projectID)->exec(); + } + } + /** * All project. * diff --git a/module/project/js/story.js b/module/project/js/story.js index 24e1358871..08d74073cb 100644 --- a/module/project/js/story.js +++ b/module/project/js/story.js @@ -2,6 +2,13 @@ $(function() { ajaxGetSearchForm(); + $('#storyList').on('sort.sortable', function(e, data) + { + var list = ''; + for(i = 0; i < data.list.length; i++) list += $(data.list[i]).attr('data-id') + ','; + $.post(createLink('project', 'storySort', 'projectID=' + projectID), {'storys' : list, 'orderBy' : orderBy}); + }); + fixedTfootAction('#projectStoryForm'); fixedTheadOfList('#storyList'); diff --git a/module/project/view/story.html.php b/module/project/view/story.html.php index b73fb46c91..d66a3a994a 100644 --- a/module/project/view/story.html.php +++ b/module/project/view/story.html.php @@ -12,6 +12,7 @@ ?> + project->confirmUnlinkStory)?> @@ -55,6 +56,7 @@