diff --git a/lib/base/dao/dao.class.php b/lib/base/dao/dao.class.php index 8fdbd87b49..f1a0959012 100644 --- a/lib/base/dao/dao.class.php +++ b/lib/base/dao/dao.class.php @@ -1917,13 +1917,14 @@ class baseSQL if($this->inCondition and !$this->conditionIsTrue) return $this; $order = str_replace(array('|', '', '_'), ' ', $order); - if(!preg_match('/^(\w+\.)?(`\w+`|\w+)( +(desc|asc))?( *(, *(\w+\.)?(`\w+`|\w+)( +(desc|asc))?)?)*$/i', $order))die("Order is bad request, The order is $order"); /* Add "`" in order string. */ /* When order has limit string. */ $pos = stripos($order, 'limit'); $orders = $pos ? substr($order, 0, $pos) : $order; $limit = $pos ? substr($order, $pos) : ''; + $orders = trim($orders); + if(!preg_match('/^(\w+\.)?(`\w+`|\w+)( +(desc|asc))?( *(, *(\w+\.)?(`\w+`|\w+)( +(desc|asc))?)?)*$/i', $orders))die("Order is bad request, The order is $orders"); $orders = explode(',', $orders); foreach($orders as $i => $order) diff --git a/module/file/model.php b/module/file/model.php index 60b9697051..ff63a48d7d 100644 --- a/module/file/model.php +++ b/module/file/model.php @@ -42,13 +42,19 @@ class fileModel extends model */ public function getByObject($objectType, $objectID, $extra = '') { - return $this->dao->select('*')->from(TABLE_FILE) + $files = $this->dao->select('*')->from(TABLE_FILE) ->where('objectType')->eq($objectType) ->andWhere('objectID')->eq((int)$objectID) ->andWhere('extra')->ne('editor') ->beginIF($extra)->andWhere('extra')->eq($extra) ->orderBy('id') ->fetchAll('id'); + foreach($files as $file) + { + $file->webPath = $this->webPath . $file->pathname; + $file->realPath = $this->app->getAppRoot() . "www/data/upload/{$this->app->company->id}/" . $file->pathname; + } + return $files; } /** diff --git a/module/story/model.php b/module/story/model.php index 9deda76eec..da7e05d6c9 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -448,6 +448,7 @@ class storyModel extends model ->add('lastEditedDate', $now) ->setDefault('status', $oldStory->status) ->setDefault('product', $oldStory->product) + ->setDefault('plan', $oldStory->plan) ->setDefault('branch', 0) ->setIF($this->post->assignedTo != $oldStory->assignedTo, 'assignedDate', $now) ->setIF($this->post->closedBy != false and $oldStory->closedDate == '', 'closedDate', $now) @@ -459,6 +460,7 @@ class storyModel extends model ->remove('linkStories,childStories,files,labels,comment') ->get(); if(is_array($story->plan)) $story->plan = trim(join(',', $story->plan), ','); + if(empty($_POST['product'])) $story->branch = $oldStory->branch; $this->dao->update(TABLE_STORY) ->data($story) diff --git a/module/tree/model.php b/module/tree/model.php index e7a281b5fe..3f8b257ba7 100644 --- a/module/tree/model.php +++ b/module/tree/model.php @@ -142,7 +142,7 @@ class treeModel extends model else { $modules = $this->dao->select('id,name,path,short')->from(TABLE_MODULE) - ->where("((root = $rootID and type = 'task')") + ->where("((root = '" . (int)$rootID . "' and type = 'task')") ->orWhere('(root')->in($products)->andWhere('type')->eq('story') ->markRight(2) ->andWhere('deleted')->eq(0) @@ -198,7 +198,7 @@ class treeModel extends model $treeMenu = array(); $lastMenu[] = '/'; $projectModules = $this->getTaskTreeModules($rootID, false, false); - $noProductModules = $this->dao->select('*')->from(TABLE_MODULE)->where("root = $rootID and type = 'task' and parent = 0")->andWhere('deleted')->eq(0)->fetchPairs('id', 'name'); + $noProductModules = $this->dao->select('*')->from(TABLE_MODULE)->where("root = '" . (int)$rootID . "' and type = 'task' and parent = 0")->andWhere('deleted')->eq(0)->fetchPairs('id', 'name'); /* Fix for not in product modules. */ $productNum = count($products); @@ -208,7 +208,7 @@ class treeModel extends model { if($type == 'product') { - $modules = $this->dao->select('*')->from(TABLE_MODULE)->where("((root = $rootID and type = 'task') OR (root = $id and type = 'story'))") + $modules = $this->dao->select('*')->from(TABLE_MODULE)->where("((root = '" . (int)$rootID . "' and type = 'task') OR (root = $id and type = 'story'))") ->beginIF($startModulePath)->andWhere('path')->like($startModulePath)->fi() ->andWhere('deleted')->eq(0) ->orderBy('grade desc, branch, type, `order`') @@ -216,7 +216,7 @@ class treeModel extends model } else { - $modules = $this->dao->select('*')->from(TABLE_MODULE)->where("root = $rootID and type = 'task' and path like '%,$id,%'") + $modules = $this->dao->select('*')->from(TABLE_MODULE)->where("root = '" . (int)$rootID . "' and type = 'task' and path like '%,$id,%'") ->beginIF($startModulePath)->andWhere('path')->like($startModulePath)->fi() ->andWhere('deleted')->eq(0) ->orderBy('grade desc, type, `order`') @@ -413,7 +413,7 @@ class treeModel extends model foreach($branchGroups[$id] as $branch => $branchName) { $treeMenu = array(); - $query = $this->dao->select('*')->from(TABLE_MODULE)->where("((root = $rootID and type = 'task' and parent != 0) OR (root = $id and type = 'story' and branch ='$branch'))") + $query = $this->dao->select('*')->from(TABLE_MODULE)->where("((root = '" . (int)$rootID . "' and type = 'task' and parent != 0) OR (root = $id and type = 'story' and branch ='$branch'))") ->beginIF($startModulePath)->andWhere('path')->like($startModulePath)->fi() ->andWhere('deleted')->eq(0) ->orderBy('grade desc, type, `order`') @@ -438,7 +438,7 @@ class treeModel extends model { /* tree menu. */ $treeMenu = array(); - $query = $this->dao->select('*')->from(TABLE_MODULE)->where("root = $rootID and type = 'task'")->andWhere('deleted')->eq(0)->orderBy('grade desc, type, `order`')->get(); + $query = $this->dao->select('*')->from(TABLE_MODULE)->where("root = '" . (int)$rootID . "' and type = 'task'")->andWhere('deleted')->eq(0)->orderBy('grade desc, type, `order`')->get(); $stmt = $this->dbh->query($query); while($module = $stmt->fetch()) { @@ -491,7 +491,7 @@ class treeModel extends model if(empty($branchGroups[$id])) $branchGroups[$id]['0'] = ''; foreach($branchGroups[$id] as $branch => $branchName) { - $query = $this->dao->select('*')->from(TABLE_MODULE)->where("((root = $rootID and type = 'task' and parent != 0) OR (root = $id and type = 'story' and branch ='$branch'))") + $query = $this->dao->select('*')->from(TABLE_MODULE)->where("((root = '" . (int)$rootID . "' and type = 'task' and parent != 0) OR (root = $id and type = 'story' and branch ='$branch'))") ->andWhere('deleted')->eq(0) ->orderBy('grade desc, type, `order`') ->get(); @@ -508,7 +508,7 @@ class treeModel extends model } /* Get project module. */ - $query = $this->dao->select('*')->from(TABLE_MODULE)->where("root = $rootID and type = 'task'")->andWhere('deleted')->eq(0)->orderBy('grade desc, type, `order`')->get(); + $query = $this->dao->select('*')->from(TABLE_MODULE)->where("root = '" . (int)$rootID . "' and type = 'task'")->andWhere('deleted')->eq(0)->orderBy('grade desc, type, `order`')->get(); $stmt = $this->dbh->query($query); $taskTrees = $this->getDataStructure($stmt, 'task', $projectModules); foreach($taskTrees as $taskModule) $fullTrees[] = $taskModule;