diff --git a/module/story/control.php b/module/story/control.php index b6478e7346..5cc915f284 100644 --- a/module/story/control.php +++ b/module/story/control.php @@ -1705,4 +1705,43 @@ class story extends control if($id) die(html::select("storys[$id]", $storys, '', 'class="form-control"')); die(html::select('story', $storys, '', 'class=form-control')); } + + /** + * Ajax get story status. + * + * @param string $method + * @param string $params + * @access public + * @return void + */ + public function ajaxGetStatus($method, $params = '') + { + parse_str(str_replace(',', '&', $params), $params); + $status = ''; + if($method == 'create') + { + $status = 'draft'; + if(!empty($params['needNotReview'])) $status = 'active'; + if(!empty($params['project'])) $status = 'active'; + if($this->story->checkForceReview()) $status = 'draft'; + } + elseif($method == 'change') + { + $oldStory = $this->dao->findById((int)$params['storyID'])->from(TABLE_STORY)->fetch(); + $status = $oldStory->status; + if($params['changed'] and $oldStory->status == 'active' and empty($params['needNotReview'])) $status = 'changed'; + if($params['changed'] and $oldStory->status == 'active' and $this->story->checkForceReview()) $status = 'changed'; + if($params['changed'] and $oldStory->status == 'draft' and $params['needNotReview']) $status = 'active'; + } + elseif($method == 'review') + { + $oldStory = $this->dao->findById((int)$params['storyID'])->from(TABLE_STORY)->fetch(); + $status = $oldStory->status; + if($params['result'] == 'pass' and $oldStory->status == 'draft') $status = 'active'; + if($params['result'] == 'pass' and $oldStory->status == 'changed') $status = 'active'; + if($params['result'] == 'revert') $status = 'active'; + if($params['result'] == 'reject') $status = 'closed'; + } + die($status); + } } diff --git a/module/story/js/change.js b/module/story/js/change.js index e4b512c5a8..b94ee6d026 100644 --- a/module/story/js/change.js +++ b/module/story/js/change.js @@ -3,8 +3,30 @@ $(function() $('#needNotReview').on('change', function() { $('#assignedTo').attr('disabled', $(this).is(':checked') ? 'disabled' : null).trigger('chosen:updated'); + getStatus('change', "storyID=" + storyID + ",changed=" + changed + ",needNotReview=" + ($(this).prop('checked') ? 1 : 0)); }); $('#needNotReview').change(); + $specBox = $('#spec').closest('td').find('.ke-container iframe.ke-edit-iframe').contents().find('.article-content'); + $verifyBox = $('#verify').closest('td').find('.ke-container iframe.ke-edit-iframe').contents().find('.article-content'); + $('#title').change(function() + { + newChanged = ($(this).val() != oldStoryTitle || $specBox.html() != oldStorySpec || $verifyBox.html() != oldStoryVerify || $('.file-input-list .file-input.normal').length > 0) ? 1 : 0; + if(changed != newChanged) + { + changed = newChanged; + getStatus('change', "storyID=" + storyID + ",changed=" + changed + ",needNotReview=" + ($('#needNotReview').prop('checked') ? 1 : 0)); + } + }); + $('.ke-container iframe.ke-edit-iframe').contents().find('.article-content').keyup(function() + { + newChanged = ($('#title').val() != oldStoryTitle || $specBox.html() != oldStorySpec || $verifyBox.html() != oldStoryVerify || $('.file-input-list .file-input.normal').length > 0) ? 1 : 0; + if(changed != newChanged) + { + changed = newChanged; + getStatus('change', "storyID=" + storyID + ",changed=" + changed + ",needNotReview=" + ($('#needNotReview').prop('checked') ? 1 : 0)); + } + }); + if($('.tabs .tab-content .tab-pane.active').children().length == 0) $('.tabs .nav-tabs li.active').css('border-bottom', '1px solid #ccc'); }); diff --git a/module/story/js/common.js b/module/story/js/common.js new file mode 100644 index 0000000000..87c3fd50e4 --- /dev/null +++ b/module/story/js/common.js @@ -0,0 +1,14 @@ +function getStatus(method, params) +{ + $.get(createLink('story', 'ajaxGetStatus', "method=" + method + '¶ms=' + params), function(status) + { + if($('form #status').length == 0) + { + $('form').append(""); + } + else + { + $('form #status').val(status); + } + }); +} diff --git a/module/story/js/create.js b/module/story/js/create.js index 9c838d5288..c1f5f5bb8a 100644 --- a/module/story/js/create.js +++ b/module/story/js/create.js @@ -3,6 +3,7 @@ $(function() $('#needNotReview').on('change', function() { $('#assignedTo').attr('disabled', $(this).is(':checked') ? 'disabled' : null).trigger('chosen:updated'); + getStatus('create', "product=" + $('#product').val() + ",project=" + projectID + ",needNotReview=" + ($(this).prop('checked') ? 1 : 0)); }); $('#needNotReview').change(); diff --git a/module/story/js/review.js b/module/story/js/review.js index 3f85da5153..a609560c51 100644 --- a/module/story/js/review.js +++ b/module/story/js/review.js @@ -33,6 +33,8 @@ function switchShow(result) $('#assignedTo').val(assignedTo); $('#assignedTo').trigger("chosen:updated"); } + + getStatus('review', "storyID=" + storyID + ",result=" + result); } function setStory(reason) diff --git a/module/story/view/change.html.php b/module/story/view/change.html.php index b8821e3f05..33a9498b9f 100644 --- a/module/story/view/change.html.php +++ b/module/story/view/change.html.php @@ -78,4 +78,9 @@ +id);?> +title);?> +spec);?> +verify);?> + diff --git a/module/story/view/close.html.php b/module/story/view/close.html.php index 3208de9fc9..ad08605ac3 100644 --- a/module/story/view/close.html.php +++ b/module/story/view/close.html.php @@ -44,6 +44,7 @@ + goback, $app->session->storyList ? $app->session->storyList : inlink('view', "storyID=$story->id"), 'self', '', 'btn btn-wide');?> diff --git a/module/story/view/create.html.php b/module/story/view/create.html.php index f46123ae39..ec19b0917c 100644 --- a/module/story/view/create.html.php +++ b/module/story/view/create.html.php @@ -210,5 +210,6 @@ + story->module);?> diff --git a/module/story/view/review.html.php b/module/story/view/review.html.php index 7e548c22f8..cc26f6506f 100644 --- a/module/story/view/review.html.php +++ b/module/story/view/review.html.php @@ -89,4 +89,5 @@ var assignedTo = 'lastEditedBy ? print($story->lastEditedBy) : pri
+id);?> diff --git a/module/translate/model.php b/module/translate/model.php index 932ec13f53..e990466815 100644 --- a/module/translate/model.php +++ b/module/translate/model.php @@ -640,7 +640,8 @@ class translateModel extends model $result = true; $tolowerValue = strtolower($value); if($tolowerValue == 'new stdclass()' or $tolowerValue == 'new stdclass') $result = false; - if(strpos($value, '$') === 0 and strpos($value, '$lang->productCommon') === false and strpos($value, '$lang->projectCommon') === false and strpos($value, '.') === false and !preg_match('/[^\$\-\>\w\'\"\[\]]/', $value)) $result = false; + /* Check for only php variable. */ + if(strpos($value, '$') === 0 and $value != '$' and strpos($value, '$lang->productCommon') === false and strpos($value, '$lang->projectCommon') === false and strpos($value, '.') === false and !preg_match('/[^\$\-\>\w\'\"\[\]]/', $value)) $result = false; if($value == '$lang->productCommon' or $value == '$lang->projectCommon') $result = false; return $result; diff --git a/module/tree/view/browse.html.php b/module/tree/view/browse.html.php index 1d2bc30d71..5327ed74b5 100644 --- a/module/tree/view/browse.html.php +++ b/module/tree/view/browse.html.php @@ -242,6 +242,8 @@ $(function() $('#modulesTree').find('li:not(.tree-action-item)').each(function() { var $li = $(this); + if($li.hasClass('tree-item-branch')) return; + var item = $li.data(); orders['orders[' + item.id + ']'] = $li.attr('data-order') || item.order; });