From fd39d31c1b0c8188b4da12fe226bed46e4822183 Mon Sep 17 00:00:00 2001 From: wangchunsheng Date: Mon, 12 Apr 2010 06:19:24 +0000 Subject: [PATCH] * when left join the use table, add company condition. --- trunk/module/group/model.php | 1 + trunk/module/project/model.php | 8 ++++++-- trunk/module/task/model.php | 3 +++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/trunk/module/group/model.php b/trunk/module/group/model.php index 24a76f41e0..00cdd2d857 100644 --- a/trunk/module/group/model.php +++ b/trunk/module/group/model.php @@ -111,6 +111,7 @@ class groupModel extends model ->from(TABLE_USERGROUP)->alias('t1') ->leftJoin(TABLE_USER)->alias('t2')->on('t1.account = t2.account') ->where('`group`')->eq((int)$groupID) + ->andWhere('t2.company')->eq($this->app->company->id) ->fetchPairs(); } diff --git a/trunk/module/project/model.php b/trunk/module/project/model.php index bb587a5237..2cb7d3d864 100644 --- a/trunk/module/project/model.php +++ b/trunk/module/project/model.php @@ -318,7 +318,9 @@ class projectModel extends model { return $this->dao->select('t1.*, t2.realname')->from(TABLE_TEAM)->alias('t1') ->leftJoin(TABLE_USER)->alias('t2')->on('t1.account = t2.account') - ->where('t1.project')->eq((int)$projectID)->fetchAll(); + ->where('t1.project')->eq((int)$projectID) + ->andWHere('t2.company')->eq($this->app->company->id) + ->fetchAll(); } /* 获取团队成员account=>name列表。*/ @@ -326,7 +328,9 @@ class projectModel extends model { $users = $this->dao->select('t1.account, t2.realname')->from(TABLE_TEAM)->alias('t1') ->leftJoin(TABLE_USER)->alias('t2')->on('t1.account = t2.account') - ->where('t1.project')->eq((int)$projectID)->fetchPairs(); + ->where('t1.project')->eq((int)$projectID) + ->andWHere('t2.company')->eq($this->app->company->id) + ->fetchPairs(); if(!$users) return array(); foreach($users as $account => $realName) { diff --git a/trunk/module/task/model.php b/trunk/module/task/model.php index 5d0708a783..ef651f9c38 100644 --- a/trunk/module/task/model.php +++ b/trunk/module/task/model.php @@ -106,6 +106,7 @@ class taskModel extends model ->leftJoin(TABLE_USER)->alias('t3') ->on('t1.owner = t3.account') ->where('t1.id')->eq((int)$taskID) + ->andWhere('t3.company')->eq($this->app->company->id) ->fetch(); if(!$task) return false; $task->files = $this->loadModel('file')->getByObject('task', $taskID); @@ -125,6 +126,7 @@ class taskModel extends model ->where('t1.project')->eq((int)$projectID) ->onCaseOf($status == 'needConfirm')->andWhere('t2.version > t1.storyVersion')->andWhere("t2.status = 'active'")->endCase() ->onCaseOf($status != 'all' and $status != 'needConfirm')->andWhere('t1.status')->in($status)->endCase() + ->andWhere('t3.company')->eq($this->app->company->id) ->orderBy($orderBy) ->page($pager) ->fetchAll(); @@ -142,6 +144,7 @@ class taskModel extends model ->on('t1.owner = t2.account') ->where('t1.project')->eq((int)$projectID) ->onCaseOf($status != 'all')->andWhere('t1.status')->in($status)->endCase() + ->andWhere('t2.company')->eq($this->app->company->id) ->orderBy($orderBy) ->query(); while($task = $stmt->fetch()) $tasks[$task->id] = "$task->id:$task->ownerRealName:$task->name";