From 5f8bfb7743199fd98f795fd7c4d2946bab6e98ad Mon Sep 17 00:00:00 2001 From: wangyidong Date: Tue, 2 Jul 2013 08:15:31 +0000 Subject: [PATCH] * finish task #1483. --- db/update4.1.sql | 38 +++++++++++++ lib/dao/dao.class.php | 75 +++++-------------------- module/action/model.php | 2 +- module/bug/control.php | 4 +- module/convert/control.php | 6 +- module/convert/converter/bugfree1.php | 16 +++--- module/convert/converter/bugfree2.php | 22 ++++---- module/convert/converter/redmine1.1.php | 30 +++++----- module/file/model.php | 4 +- module/group/model.php | 8 +-- module/install/model.php | 9 +-- module/project/model.php | 2 - module/setting/model.php | 26 +++------ module/story/control.php | 4 +- module/story/model.php | 1 - module/task/control.php | 2 +- module/testtask/control.php | 2 +- module/testtask/model.php | 2 +- module/todo/control.php | 1 - module/upgrade/model.php | 42 ++++---------- module/user/control.php | 2 +- module/user/model.php | 8 +-- module/user/view/profile.html.php | 2 +- module/webapp/model.php | 2 +- 24 files changed, 129 insertions(+), 181 deletions(-) diff --git a/db/update4.1.sql b/db/update4.1.sql index 7f73c7bc2c..829d642bcd 100644 --- a/db/update4.1.sql +++ b/db/update4.1.sql @@ -7,3 +7,41 @@ ALTER TABLE `zt_project` DROP `order`; ALTER TABLE `zt_story` CHANGE `reviewedBy` `reviewedBy` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL; ALTER TABLE `zt_build` DROP INDEX `name`; + +ALTER TABLE `zt_action` DROP `company`; +ALTER TABLE `zt_bug` DROP `company`; +ALTER TABLE `zt_build` DROP `company`; +ALTER TABLE `zt_burn` DROP `company`; +ALTER TABLE `zt_case` DROP `company`; +ALTER TABLE `zt_caseStep` DROP `company`; +ALTER TABLE `zt_config` DROP `company`; +ALTER TABLE `zt_dept` DROP `company`; +ALTER TABLE `zt_doc` DROP `company`; +ALTER TABLE `zt_docLib` DROP `company`; +ALTER TABLE `zt_extension` DROP `company`; +ALTER TABLE `zt_file` DROP `company`; +ALTER TABLE `zt_group` DROP `company`; +ALTER TABLE `zt_groupPriv` DROP `company`; +ALTER TABLE `zt_history` DROP `company`; +ALTER TABLE `zt_module` DROP `company`; +ALTER TABLE `zt_product` DROP `company`; +ALTER TABLE `zt_productPlan` DROP `company`; +ALTER TABLE `zt_project` DROP `company`; +ALTER TABLE `zt_projectProduct` DROP `company`; +ALTER TABLE `zt_projectStory` DROP `company`; +ALTER TABLE `zt_release` DROP `company`; +ALTER TABLE `zt_story` DROP `company`; +ALTER TABLE `zt_storySpec` DROP `company`; +ALTER TABLE `zt_task` DROP `company`; +ALTER TABLE `zt_taskEstimate` DROP `company`; +ALTER TABLE `zt_team` DROP `company`; +ALTER TABLE `zt_testResult` DROP `company`; +ALTER TABLE `zt_testRun` DROP `company`; +ALTER TABLE `zt_testTask` DROP `company`; +ALTER TABLE `zt_todo` DROP `company`; +ALTER TABLE `zt_user` DROP `company`; +ALTER TABLE `zt_userContact` DROP `company`; +ALTER TABLE `zt_userGroup` DROP `company`; +ALTER TABLE `zt_userQuery` DROP `company`; +ALTER TABLE `zt_userTPL` DROP `company`; +ALTER TABLE `zt_webapp` DROP `company`; diff --git a/lib/dao/dao.class.php b/lib/dao/dao.class.php index f8c426ba8a..f5310fb045 100755 --- a/lib/dao/dao.class.php +++ b/lib/dao/dao.class.php @@ -347,14 +347,12 @@ class dao * Set the data to update or insert. * * @param object $data the data object or array - * @param bool $autoCompany auto append company field or not * @access public * @return object the dao object self. */ - public function data($data, $autoCompany = true) + public function data($data) { if(!is_object($data)) $data = (object)$data; - if($autoCompany and isset($this->app->company) and $this->table != TABLE_COMPANY and !isset($data->company)) $data->company = $this->app->company->id; $this->sqlobj->data($data); return $this; } @@ -386,11 +384,10 @@ class dao /** * Process the sql, replace the table, fields and add the company condition. * - * @param bool $autoCompany * @access private * @return string the sql string after process. */ - private function processSQL($autoCompany = true) + private function processSQL() { $sql = $this->sqlobj->get(); @@ -402,42 +399,6 @@ class dao $sql = sprintf($this->sqlobj->get(), $this->fields, $this->table); } - /* If the method is select, update or delete, set the comapny condition. */ - if(isset($this->app->company) and $autoCompany and $this->table != '' and $this->table != TABLE_COMPANY and $this->method != 'insert' and $this->method != 'replace') - { - /* Get the position to insert company = ?. */ - $wherePOS = strrpos($sql, DAO::WHERE); // The position of WHERE keyword. - $groupPOS = strrpos($sql, DAO::GROUPBY); // The position of GROUP BY keyword. - $havingPOS = strrpos($sql, DAO::HAVING); // The position of HAVING keyword. - $orderPOS = strrpos($sql, DAO::ORDERBY); // The position of ORDERBY keyword. - $limitPOS = strrpos($sql, DAO::LIMIT); // The position of LIMIT keyword. - $splitPOS = $orderPOS ? $orderPOS : $limitPOS; // If $orderPOS, use it instead of $limitPOS. - $splitPOS = $havingPOS? $havingPOS: $splitPOS; // If $havingPOS, use it instead of $orderPOS. - $splitPOS = $groupPOS ? $groupPOS : $splitPOS; // If $groupPOS, use it instead of $havingPOS. - - /* Set the conditon to be appened. */ - $tableName = !empty($this->alias) ? $this->alias : $this->table; - $companyCondition = " $tableName.company = '{$this->app->company->id}' "; - - /* If $spliPOS > 0, split the sql at $splitPOS. */ - if($splitPOS) - { - $firstPart = substr($sql, 0, $splitPOS); - $lastPart = substr($sql, $splitPOS); - if($wherePOS) - { - $sql = $firstPart . " AND $companyCondition " . $lastPart; - } - else - { - $sql = $firstPart . " WHERE $companyCondition " . $lastPart; - } - } - else - { - $sql .= $wherePOS ? " AND $companyCondition" : " WHERE $companyCondition"; - } - } self::$querys[] = $this->processKeywords($sql); return $sql; } @@ -474,15 +435,14 @@ class dao /** * Query the sql, return the statement object. * - * @param bool $autoCompany * @access public * @return object the PDOStatement object. */ - public function query($autoCompany = true) + public function query() { if(!empty(dao::$errors)) return new PDOStatement(); // If any error, return an empty statement object to make sure the remain method to execute. - $sql = $this->processSQL($autoCompany); + $sql = $this->processSQL(); try { $method = $this->method; @@ -553,15 +513,14 @@ class dao /** /* Execute the sql. It's different with query(), which return the stmt object. But this not. * - * @param bool $autoCompany * @access public * @return int the modified or deleted records. */ - public function exec($autoCompany = true) + public function exec() { if(!empty(dao::$errors)) return new PDOStatement(); // If any error, return an empty statement object to make sure the remain method to execute. - $sql = $this->processSQL($autoCompany); + $sql = $this->processSQL(); try { $this->reset(); @@ -579,15 +538,14 @@ class dao * Fetch one record. * * @param string $field if the field is set, only return the value of this field, else return this record - * @param bool $autoCompany * @access public * @return object|mixed */ - public function fetch($field = '', $autoCompany = true) + public function fetch($field = '') { - if(empty($field)) return $this->query($autoCompany)->fetch(); + if(empty($field)) return $this->query()->fetch(); $this->setFields($field); - $result = $this->query($autoCompany)->fetch(PDO::FETCH_OBJ); + $result = $this->query()->fetch(PDO::FETCH_OBJ); if($result) return $result->$field; } @@ -595,13 +553,12 @@ class dao * Fetch all records. * * @param string $keyField the key field, thus the return records is keyed by this field - * @param bool $autoCompany * @access public * @return array the records */ - public function fetchAll($keyField = '', $autoCompany = true) + public function fetchAll($keyField = '') { - $stmt = $this->query($autoCompany); + $stmt = $this->query(); if(empty($keyField)) return $stmt->fetchAll(); $rows = array(); while($row = $stmt->fetch()) $rows[$row->$keyField] = $row; @@ -613,13 +570,12 @@ class dao * * @param string $groupField the field to group by * @param string $keyField the field of key - * @param bool $autoCompany * @access public * @return array the records. */ - public function fetchGroup($groupField, $keyField = '', $autoCompany = true) + public function fetchGroup($groupField, $keyField = '') { - $stmt = $this->query($autoCompany); + $stmt = $this->query(); $rows = array(); while($row = $stmt->fetch()) { @@ -635,15 +591,14 @@ class dao * * @param string $keyField * @param string $valueField - * @param bool $autoCompany * @access public * @return array */ - public function fetchPairs($keyField = '', $valueField = '', $autoCompany = true) + public function fetchPairs($keyField = '', $valueField = '') { $pairs = array(); $ready = false; - $stmt = $this->query($autoCompany); + $stmt = $this->query(); while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { if(!$ready) diff --git a/module/action/model.php b/module/action/model.php index 6e1f861d57..6d85135c2d 100644 --- a/module/action/model.php +++ b/module/action/model.php @@ -84,7 +84,7 @@ class actionModel extends model foreach($objectList as $object => $table) { - $idList = $this->dao->select('id')->from($table)->where('assignedTo')->eq($this->app->user->account)->fetchPairs('id', '', false); + $idList = $this->dao->select('id')->from($table)->where('assignedTo')->eq($this->app->user->account)->fetchPairs('id', ''); $tmpActions = $this->dao->select('*')->from(TABLE_ACTION) ->where('objectType')->eq($object) diff --git a/module/bug/control.php b/module/bug/control.php index a142f5a44e..c9a6a1166b 100644 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -1095,7 +1095,7 @@ class bug extends control { foreach($relatedFiles[$bug->id] as $file) { - $fileURL = 'http://' . $this->server->http_host . $this->config->webRoot . "data/upload/$bug->company/" . $file->pathname; + $fileURL = 'http://' . $this->server->http_host . $this->config->webRoot . "data/upload/{$this->app->company->id}/" . $file->pathname; $bug->files .= html::a($fileURL, $file->title, '_blank') . '
'; } } @@ -1109,8 +1109,6 @@ class bug extends control if(isset($users[$mailto])) $bug->mailto .= $users[$mailto] . ','; } - /* drop some field that is not needed. */ - unset($bug->company); unset($bug->caseVersion); unset($bug->result); unset($bug->deleted); diff --git a/module/convert/control.php b/module/convert/control.php index 52dd7dfb84..6a28ece431 100644 --- a/module/convert/control.php +++ b/module/convert/control.php @@ -153,9 +153,9 @@ class convert extends control $checkInfo['db'] = $converter->connectDB(); $checkInfo['path'] = $converter->checkPath(); - $this->view->trackers = $this->dao->dbh($converter->sourceDBH)->select('id, name')->from('trackers')->fetchAll('id', $autoCompany = false); - $this->view->statuses = $this->dao->dbh($converter->sourceDBH)->select('id, name')->from('issue_statuses')->fetchAll('id', $autoCompany = false); - $this->view->pries = $this->dao->dbh($converter->sourceDBH)->select('id, name')->from('enumerations')->where('type')->eq('IssuePriority')->fetchAll('id', $autoCompany = false); + $this->view->trackers = $this->dao->dbh($converter->sourceDBH)->select('id, name')->from('trackers')->fetchAll('id'); + $this->view->statuses = $this->dao->dbh($converter->sourceDBH)->select('id, name')->from('issue_statuses')->fetchAll('id'); + $this->view->pries = $this->dao->dbh($converter->sourceDBH)->select('id, name')->from('enumerations')->where('type')->eq('IssuePriority')->fetchAll('id'); /* Compute the checking result. */ $result = 'pass'; if(!is_object($checkInfo['db']) or !$checkInfo['path']) $result = 'fail'; diff --git a/module/convert/converter/bugfree1.php b/module/convert/converter/bugfree1.php index 6d9930c16c..b504f62665 100644 --- a/module/convert/converter/bugfree1.php +++ b/module/convert/converter/bugfree1.php @@ -43,7 +43,7 @@ class bugfree1ConvertModel extends bugfreeConvertModel $groups = $this->dao->dbh($this->sourceDBH) ->select("groupID AS id, groupName AS name, groupUser AS users") ->from('BugGroup') - ->fetchAll('id', $autoCompany = false); + ->fetchAll('id'); foreach($groups as $groupID => $group) { /* Explode into array. */ @@ -78,10 +78,10 @@ class bugfree1ConvertModel extends bugfreeConvertModel ->select("username AS account, userpassword AS password, realname, email") ->from('BugUser') ->orderBy('userID ASC') - ->fetchAll('account', $autoCompany = false); + ->fetchAll('account'); /* Get users in histories. */ - $allUsers = $this->dao->select("distinct(username) AS account")->from('BugHistory')->fetchPairs('', '', $autoCompany = false); + $allUsers = $this->dao->select("distinct(username) AS account")->from('BugHistory')->fetchPairs('', ''); /* Merge them. */ foreach($allUsers as $key => $account) @@ -122,7 +122,7 @@ class bugfree1ConvertModel extends bugfreeConvertModel */ public function convertProject() { - $projects = $this->dao->dbh($this->sourceDBH)->select("projectID AS id, projectName AS name")->from('BugProject')->fetchAll('id', $autoCompany = false); + $projects = $this->dao->dbh($this->sourceDBH)->select("projectID AS id, projectName AS name")->from('BugProject')->fetchAll('id'); foreach($projects as $projectID => $project) { unset($project->id); @@ -152,7 +152,7 @@ class bugfree1ConvertModel extends bugfreeConvertModel "bug" AS type') ->from('BugModule') ->orderBy('id ASC') - ->fetchAll('id', $autoCompany = false); + ->fetchAll('id'); foreach($modules as $moduleID => $module) { $module->root = $this->map['product'][$module->root]; @@ -200,7 +200,7 @@ class bugfree1ConvertModel extends bugfreeConvertModel ') ->from('BugInfo') ->orderBy('bugID') - ->fetchAll('id', $autoCompany = false); + ->fetchAll('id'); foreach($bugs as $bugID => $bug) { /* Adjust some fields of bug. */ @@ -244,7 +244,7 @@ class bugfree1ConvertModel extends bugfreeConvertModel actionDate AS date") ->from('BugHistory') ->orderBy('bugID, historyID') - ->fetchGroup('objectID', '', $autoCompany = false); + ->fetchGroup('objectID', ''); $convertCount = 0; foreach($actions as $bugID => $bugActions) { @@ -290,7 +290,7 @@ class bugfree1ConvertModel extends bugfreeConvertModel ") ->from('BugFile') ->orderBy('fileID') - ->fetchAll('', $autoCompany = false); + ->fetchAll(''); foreach($files as $file) { $file->objectID = $this->map['bug'][(int)$file->objectID]; diff --git a/module/convert/converter/bugfree2.php b/module/convert/converter/bugfree2.php index bed2293d61..689037cd29 100644 --- a/module/convert/converter/bugfree2.php +++ b/module/convert/converter/bugfree2.php @@ -68,7 +68,7 @@ class bugfree2ConvertModel extends bugfreeConvertModel return $this->dao->dbh($this->sourceDBH) ->select("optionValue as version")->from(BUGFREE_TABLE_OPTION) ->where('OptionName')->eq('dbVersion') - ->fetch('version', $autoCompany = false); + ->fetch('version'); } @@ -86,7 +86,7 @@ class bugfree2ConvertModel extends bugfreeConvertModel ->select("username AS account, userpassword AS password, realname, email, isDroped AS deleted") ->from(BUGFREE_TABLE_USER) ->orderBy('userID ASC') - ->fetchAll('account', $autoCompany = false); + ->fetchAll('account'); /* Insert into zentao. */ $convertCount = 0; @@ -117,7 +117,7 @@ class bugfree2ConvertModel extends bugfreeConvertModel $groups = $this->dao->dbh($this->sourceDBH) ->select("groupID AS id, groupName AS name, groupUser AS users") ->from(BUGFREE_TABLE_GROUP) - ->fetchAll('id', $autoCompany = false); + ->fetchAll('id'); foreach($groups as $groupID => $group) { /* Fix the group data. */ @@ -153,7 +153,7 @@ class bugfree2ConvertModel extends bugfreeConvertModel $projects = $this->dao->dbh($this->sourceDBH) ->select("projectID AS id, projectName AS name, isDroped AS deleted") ->from(BUGFREE_TABLE_PROJECT) - ->fetchAll('id', $autoComapny = false); + ->fetchAll('id'); foreach($projects as $projectID => $project) { unset($project->id); @@ -184,7 +184,7 @@ class bugfree2ConvertModel extends bugfreeConvertModel displayOrder AS `order`') ->from(BUGFREE_TABLE_MODULE) ->orderBy('id ASC') - ->fetchAll('id', $autoCompany = false); + ->fetchAll('id'); foreach($modules as $moduleID => $module) { $module->root = $this->map['product'][$module->root]; @@ -244,7 +244,7 @@ class bugfree2ConvertModel extends bugfreeConvertModel ->from(BUGFREE_TABLE_BUGINFO) ->where('isDroped')->eq(0) ->orderBy('bugID') - ->fetchAll('id', $autoCompany = false); + ->fetchAll('id'); foreach($bugs as $bugID => $bug) { /* Fix some fileds of bug. */ @@ -314,7 +314,7 @@ class bugfree2ConvertModel extends bugfreeConvertModel ->from(BUGFREE_TABLE_CASEINFO) ->where('isDroped')->eq(0) ->orderBy('caseID') - ->fetchAll('id', $autoCompany = false); + ->fetchAll('id'); foreach($cases as $caseID => $case) { /* Fix fields of case. */ @@ -380,7 +380,7 @@ class bugfree2ConvertModel extends bugfreeConvertModel ') ->from(BUGFREE_TABLE_RESULTINFO) ->orderBy('id') - ->fetchAll('id', $autoCompany = false); + ->fetchAll('id'); foreach($results as $resultID => $result) { unset($result->id); @@ -422,7 +422,7 @@ class bugfree2ConvertModel extends bugfreeConvertModel ->from(BUGFREE_TABLE_ACTION) ->where('actionTarget' != 'Result') ->orderBy('actionID') - ->fetchAll('id', $autoComapny = false); + ->fetchAll('id'); foreach($actions as $actionID => $action) { @@ -450,7 +450,7 @@ class bugfree2ConvertModel extends bugfreeConvertModel ->select('actioID, actionField AS field, oldValue AS old, newValue AS new') ->from(BUGFREE_TABLE_HISTORY) ->orderBy('historyID') - ->fetchAll('', $autoCompany = false); + ->fetchAll(''); foreach($histories as $history) { $history->actionID = $this->map['action'][$history->actionID]; @@ -477,7 +477,7 @@ class bugfree2ConvertModel extends bugfreeConvertModel ") ->from(BUGFREE_TABLE_FILE) ->orderBy('fileID') - ->fetchAll('', $autoCompany = false); + ->fetchAll(''); foreach($files as $file) { /* Get the actionID in zentao, to get file info. */ diff --git a/module/convert/converter/redmine1.1.php b/module/convert/converter/redmine1.1.php index c99dd5bffe..f257d294ab 100644 --- a/module/convert/converter/redmine1.1.php +++ b/module/convert/converter/redmine1.1.php @@ -148,7 +148,7 @@ class redmine11ConvertModel extends redmineConvertModel ->select("id, lastName AS name") ->from(REDMINE_TABLE_USERS) ->where('type')->eq('Group') - ->fetchAll('id', $autoCompany = false); + ->fetchAll('id'); $zentaoGroupNames = $this->dao->dbh($this->dbh)->select('id, name')->from(TABLE_GROUP)->fetchPairs(); $zentaoGroupIDs = $this->dao->dbh($this->dbh)->select('name, id')->from(TABLE_GROUP)->fetchPairs(); @@ -187,7 +187,7 @@ class redmine11ConvertModel extends redmineConvertModel ->select("id, login AS account, firstname, lastname, mail as email") ->from(REDMINE_TABLE_USERS) ->where('type')->eq('User') - ->fetchAll('id', $autoCompany = false); + ->fetchAll('id'); $zentaoUserNames = $this->dao->dbh($this->dbh)->select('id, account')->from(TABLE_USER)->fetchPairs(); $zentaoUserIDs = $this->dao->dbh($this->dbh)->select('account, id')->from(TABLE_USER)->fetchPairs(); @@ -230,7 +230,7 @@ class redmine11ConvertModel extends redmineConvertModel ->select("t1.group_id, t2.login as account") ->from(REDMINE_TABLE_GROUPS_USERS)->alias('t1') ->leftJoin(REDMINE_TABLE_USERS)->alias('t2')->on('t1.user_id = t2.id') - ->fetchAll('', $autoCompany = false); + ->fetchAll(''); $zentaoUserGroups = $this->dao->dbh($this->dbh)->select('*')->from(TABLE_USERGROUP)->fetchAll(); @@ -266,7 +266,7 @@ class redmine11ConvertModel extends redmineConvertModel $products = $this->dao->dbh($this->sourceDBH) ->select("id, name, description as `desc`, created_on as createdDate") ->from(REDMINE_TABLE_PROJECTS) - ->fetchAll('id', $autoComapny = false); + ->fetchAll('id'); /* Insert into zentao */ foreach($products as $productID => $product) @@ -290,7 +290,7 @@ class redmine11ConvertModel extends redmineConvertModel $projects = $this->dao->dbh($this->sourceDBH) ->select("id, name, project_id, description as `desc`, effective_date AS end") ->from(REDMINE_TABLE_VERSIONS) - ->fetchAll('id', $autoComapny = false); + ->fetchAll('id'); /* Insert into zentao */ foreach($projects as $projectID => $project) @@ -326,7 +326,7 @@ class redmine11ConvertModel extends redmineConvertModel $buildAndReleases = $this->dao->dbh($this->sourceDBH) ->select("id, name, project_id, description as `desc`, effective_date AS date") ->from(REDMINE_TABLE_VERSIONS) - ->fetchAll('id', $autoCompany = false); + ->fetchAll('id'); /* Insert into zentao */ $convertBuildsCount = 0; @@ -381,7 +381,7 @@ class redmine11ConvertModel extends redmineConvertModel $productPlans = $this->dao->dbh($this->sourceDBH) ->select("id, name as title, project_id, description as `desc`, effective_date as end, created_on AS begin") ->from(REDMINE_TABLE_VERSIONS) - ->fetchAll('id', $autoCompany = false); + ->fetchAll('id'); /* Insert into zentao */ foreach($productPlans as $id => $productPlan) { @@ -437,7 +437,7 @@ class redmine11ConvertModel extends redmineConvertModel ->from(REDMINE_TABLE_MEMBERS)->alias('t1') ->leftJoin(REDMINE_TABLE_USERS)->alias('t2')->on('t1.user_id = t2.id') ->where('t2.type')->eq('User') - ->fetchAll('', $autoCompany = false); + ->fetchAll(''); /* Insert into zentao */ foreach($teams as $team) @@ -465,7 +465,7 @@ class redmine11ConvertModel extends redmineConvertModel $docLibs = $this->dao->dbh($this->sourceDBH) ->select("id, name")->from(REDMINE_TABLE_ENUMERATIONS) ->where('type')->eq('DocumentCategory') - ->fetchAll('id', $autoCompany = false); + ->fetchAll('id'); /* Insert into zentao */ foreach($docLibs as $docLibID => $docLib) @@ -490,7 +490,7 @@ class redmine11ConvertModel extends redmineConvertModel ->select("t1.id, t1.project_id AS product, t2.id AS lib, t1.title, t1.description AS content, t1.created_on AS addedDate") ->from(REDMINE_TABLE_DOCUMENTS)->alias('t1') ->leftjoin(REDMINE_TABLE_ENUMERATIONS)->alias('t2')->on('t1.category_id = t2.id') - ->fetchAll('id', $autoCompany = false); + ->fetchAll('id'); /* Insert into zentao */ foreach($docs as $docID => $doc) @@ -519,7 +519,7 @@ class redmine11ConvertModel extends redmineConvertModel ->select("t1.project_id as product, t1.title, t1.summary as digest, t1.description as content, t2.login as addedBy, t1.created_on as addedDate") ->from(REDMINE_TABLE_NEWS)->alias('t1') ->leftJoin(REDMINE_TABLE_USERS)->alias('t2')->on('t1.author_id = t2.id') - ->fetchAll('', $autoCompany = false); + ->fetchAll(''); /* Create a news docLib */ $newLib->name = 'news'; @@ -591,7 +591,7 @@ class redmine11ConvertModel extends redmineConvertModel ->leftJoin(REDMINE_TABLE_USERS)->alias('t2')->on('t1.assigned_to_id = t2.id') ->leftJoin(REDMINE_TABLE_USERS)->alias('t3')->on('t1.author_id = t3.id') ->where('t1.tracker_id')->eq($issueType) - ->fetchAll('id', $autoCompany = false); + ->fetchAll('id'); /* Insert into zentao */ foreach($stories as $issueID => $story) @@ -640,7 +640,7 @@ class redmine11ConvertModel extends redmineConvertModel ->leftJoin(REDMINE_TABLE_USERS)->alias('t2')->on('t1.assigned_to_id = t2.id') ->leftJoin(REDMINE_TABLE_USERS)->alias('t3')->on('t1.author_id = t3.id') ->where('t1.tracker_id')->eq($issueType) - ->fetchAll('id', $autoCompany = false); + ->fetchAll('id'); /* Insert into zentao */ foreach($tasks as $issueID => $task) @@ -685,7 +685,7 @@ class redmine11ConvertModel extends redmineConvertModel ->leftJoin(REDMINE_TABLE_USERS)->alias('t2')->on('t1.assigned_to_id = t2.id') ->leftJoin(REDMINE_TABLE_USERS)->alias('t3')->on('t1.author_id = t3.id') ->where('t1.tracker_id')->eq($issueType) - ->fetchAll('id', $autoCompany = false); + ->fetchAll('id'); /* Insert into zentao */ foreach($bugs as $issueID => $bug) @@ -734,7 +734,7 @@ class redmine11ConvertModel extends redmineConvertModel ->select('t1.id, t1.container_id as objectID, t1.container_type as objectType, t1.filename as title, t1.disk_filename as pathname, t1.filesize as size, t2.login as addedBy, t1.created_on as addedDate, description') ->from(REDMINE_TABLE_ATTACHMENTS)->alias('t1') ->leftJoin(REDMINE_TABLE_USERS)->alias('t2')->on('t1.author_id = t2.id') - ->fetchAll('id', $autoCompany = false); + ->fetchAll('id'); /* Insert into zentao */ foreach($files as $fileID => $file) diff --git a/module/file/model.php b/module/file/model.php index 36df021b0e..ad3d4a5de0 100644 --- a/module/file/model.php +++ b/module/file/model.php @@ -218,7 +218,7 @@ class fileModel extends model if($files = $this->getUpload($postName)) { $file = $files[0]; - $filePath = $this->dao->select('pathname')->from(TABLE_FILE)->where('id')->eq($fileID)->fetch('', false); + $filePath = $this->dao->select('pathname')->from(TABLE_FILE)->where('id')->eq($fileID)->fetch(); $pathName = $filePath->pathname; $realPathName= $this->savePath . $pathName; if(!is_dir(dirname($realPathName)))mkdir(dirname($realPathName)); @@ -227,7 +227,7 @@ class fileModel extends model $fileInfo->addedBy = $this->app->user->account; $fileInfo->addedDate = helper::now(); $fileInfo->size = $file['size']; - $this->dao->update(TABLE_FILE)->data($fileInfo, false)->where('id')->eq($fileID)->exec(false); + $this->dao->update(TABLE_FILE)->data($fileInfo)->where('id')->eq($fileID)->exec(); return true; } else diff --git a/module/group/model.php b/module/group/model.php index 226de25beb..dea054d4f6 100644 --- a/module/group/model.php +++ b/module/group/model.php @@ -98,13 +98,12 @@ class groupModel extends model /** * Get group lists. * - * @param int $companyID * @access public * @return array */ - public function getList($companyID) + public function getList() { - return $this->dao->findByCompany($companyID)->from(TABLE_GROUP)->orderBy('id')->fetchAll(); + return $this->dao->select('*')->from(TABLE_GROUP)->orderBy('id')->fetchAll(); } /** @@ -115,7 +114,7 @@ class groupModel extends model */ public function getPairs() { - return $this->dao->findByCompany($this->app->company->id)->fields('id, name')->from(TABLE_GROUP)->fetchPairs(); + return $this->dao->select('id, name')->from(TABLE_GROUP)->fetchPairs(); } /** @@ -175,7 +174,6 @@ class groupModel extends model ->leftJoin(TABLE_USER)->alias('t2')->on('t1.account = t2.account') ->where('`group`')->eq((int)$groupID) ->andWhere('t2.deleted')->eq(0) - ->andWhere('t2.company')->eq($this->app->company->id) ->orderBy('t2.account') ->fetchPairs(); } diff --git a/module/install/model.php b/module/install/model.php index 63f4ba0f91..82a28ac70f 100644 --- a/module/install/model.php +++ b/module/install/model.php @@ -397,19 +397,13 @@ class installModel extends model if(!dao::isError()) { /* Set admin. */ - $companyID = $this->dbh->lastInsertID(); $admin = new stdclass(); $admin->account = $this->post->account; $admin->realname = $this->post->account; $admin->password = md5($this->post->password); $admin->gender = ''; - $admin->company = $companyID; $this->dao->insert(TABLE_USER)->data($admin)->check('account', 'notempty')->exec(); - /* Update the group and groupPriv table. */ - $this->dao->update(TABLE_GROUP)->set('company')->eq($companyID)->exec($autoCompany = false); - $this->dao->update(TABLE_GROUPPRIV)->set('company')->eq($companyID)->exec($autoCompany = false); - /* Update group name and desc on dafault lang. */ $groups = $this->dao->select('*')->from(TABLE_GROUP)->orderBy('id')->fetchAll(); foreach($groups as $group) @@ -440,13 +434,12 @@ class installModel extends model if(!$this->dbh->query($table)) return false; } - $config->company = '1'; $config->module = 'common'; $config->owner = 'system'; $config->section = 'global'; $config->key = 'showDemoUsers'; $config->value = '1'; - $this->dao->replace(TABLE_CONFIG)->data($config, false)->exec(false); + $this->dao->replace(TABLE_CONFIG)->data($config)->exec(); return true; } diff --git a/module/project/model.php b/module/project/model.php index 560fc9a46f..a5207eb4af 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -1030,7 +1030,6 @@ class projectModel extends model return $this->dao->select('t1.*, t1.hours * t1.days AS totalHours, t2.realname')->from(TABLE_TEAM)->alias('t1') ->leftJoin(TABLE_USER)->alias('t2')->on('t1.account = t2.account') ->where('t1.project')->eq((int)$projectID) - ->andWHere('t2.company')->eq($this->app->company->id) ->fetchAll('account'); } @@ -1047,7 +1046,6 @@ 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) - ->andWHere('t2.company')->eq($this->app->company->id) ->beginIF($params == 'nodeleted') ->andWhere('t2.deleted')->eq(0) ->fi() diff --git a/module/setting/model.php b/module/setting/model.php index b87052119a..3108e4453e 100644 --- a/module/setting/model.php +++ b/module/setting/model.php @@ -24,7 +24,7 @@ class settingModel extends model */ public function getItem($paramString) { - return $this->createDAO($this->parseItemParam($paramString), 'select')->fetch('value', $autoCompany = false); + return $this->createDAO($this->parseItemParam($paramString), 'select')->fetch('value'); } /** @@ -36,7 +36,7 @@ class settingModel extends model */ public function getItems($paramString) { - return $this->createDAO($this->parseItemParam($paramString), 'select')->fetchAll('id', $autoCompany = false); + return $this->createDAO($this->parseItemParam($paramString), 'select')->fetchAll('id'); } /** @@ -44,11 +44,10 @@ class settingModel extends model * * @param string $path system.common.global.sn or system.common.sn * @param string $value - * @param string|int $company * @access public * @return void */ - public function setItem($path, $value = '', $company = 'current') + public function setItem($path, $value = '') { $level = substr_count($path, '.'); $section = ''; @@ -58,14 +57,13 @@ class settingModel extends model if($level == 3) list($owner, $module, $section, $key) = explode('.', $path); $item = new stdclass(); - $item->company = $company === 'current' ? $this->app->company->id : $company; $item->owner = $owner; $item->module = $module; $item->section = $section; $item->key = $key; $item->value = $value; - $this->dao->replace(TABLE_CONFIG)->data($item)->exec($autoCompany = false); + $this->dao->replace(TABLE_CONFIG)->data($item)->exec(); } /** @@ -80,7 +78,7 @@ class settingModel extends model * @access public * @return bool */ - public function setItems($path, $items, $company = 'current') + public function setItems($path, $items) { foreach($items as $key => $item) { @@ -111,13 +109,13 @@ class settingModel extends model */ public function deleteItems($paramString) { - $this->createDAO($this->parseItemParam($paramString), 'delete')->exec($autoCompany = false); + $this->createDAO($this->parseItemParam($paramString), 'delete')->exec(); } /** * Parse the param string for select or delete items. * - * @param string $paramString owner=xxx&company=1,2&key=sn and so on. + * @param string $paramString owner=xxx&key=sn and so on. * @access public * @return array */ @@ -127,13 +125,10 @@ class settingModel extends model parse_str($paramString, $params); /* Init fields not set in the param string. */ - $fields = 'company,owner,module,section,key'; + $fields = 'owner,module,section,key'; $fields = explode(',', $fields); foreach($fields as $field) if(!isset($params[$field])) $params[$field] = ''; - /* If not set company, set as current company. */ - if($params['company'] == '') $params['company'] = $this->app->company->id; - return $params; } @@ -148,7 +143,6 @@ class settingModel extends model public function createDAO($params, $method = 'select') { return $this->dao->$method('*')->from(TABLE_CONFIG)->where('1 = 1') - ->beginIF($params['company'])->andWhere('company')->in($params['company'])->fi() ->beginIF($params['owner'])->andWhere('owner')->in($params['owner'])->fi() ->beginIF($params['module'])->andWhere('module')->in($params['module'])->fi() ->beginIF($params['section'])->andWhere('section')->in($params['section'])->fi() @@ -164,13 +158,11 @@ class settingModel extends model */ public function getSysAndPersonalConfig($account = '') { - $company = $this->app->company->id . ',' . '0'; // Get settings of current company, and also settings for all company. $owner = 'system,' . ($account ? $account : ''); $records = $this->dao->select('*')->from(TABLE_CONFIG) ->where('owner')->in($owner) - ->andWhere('company')->in($company) ->orderBy('id') - ->fetchAll('id', false); + ->fetchAll('id'); if(!$records) return array(); /* Group records by owner and module. */ diff --git a/module/story/control.php b/module/story/control.php index d9aadec5dc..8a8b0fc8e9 100644 --- a/module/story/control.php +++ b/module/story/control.php @@ -912,7 +912,7 @@ class story extends control { $stories = $this->dao->select('*')->from(TABLE_STORY)->where($this->session->storyQueryCondition) ->beginIF($this->post->exportType == 'selected')->andWhere('id')->in($this->cookie->checkedItem)->fi() - ->orderBy($orderBy)->fetchAll('id', false); + ->orderBy($orderBy)->fetchAll('id'); } else { @@ -1023,7 +1023,7 @@ class story extends control { foreach($relatedFiles[$story->id] as $file) { - $fileURL = 'http://' . $this->server->http_host . $this->config->webRoot . "data/upload/$story->company/" . $file->pathname; + $fileURL = 'http://' . $this->server->http_host . $this->config->webRoot . "data/upload/{$this->app->company->id}/" . $file->pathname; $story->files .= html::a($fileURL, $file->title, '_blank') . '
'; } } diff --git a/module/story/model.php b/module/story/model.php index a2d92a9db4..8a7418046b 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -137,7 +137,6 @@ class storyModel extends model if($projectID != 0) { $this->dao->insert(TABLE_PROJECTSTORY) - ->set('company')->eq(1) ->set('project')->eq($projectID) ->set('product')->eq($this->post->product) ->set('story')->eq($storyID) diff --git a/module/task/control.php b/module/task/control.php index 3242d54c51..4fe97b9508 100644 --- a/module/task/control.php +++ b/module/task/control.php @@ -966,7 +966,7 @@ class task extends control { foreach($relatedFiles[$task->id] as $file) { - $fileURL = 'http://' . $this->server->http_host . $this->config->webRoot . "data/upload/$task->company/" . $file->pathname; + $fileURL = 'http://' . $this->server->http_host . $this->config->webRoot . "data/upload/{$this->app->company->id}/" . $file->pathname; $task->files .= html::a($fileURL, $file->title, '_blank') . '
'; } } diff --git a/module/testtask/control.php b/module/testtask/control.php index 26853ea690..2acc7d4beb 100644 --- a/module/testtask/control.php +++ b/module/testtask/control.php @@ -627,7 +627,7 @@ class testtask extends control $case = $this->testtask->getRunById($runID)->case; $results = $this->testtask->getResults($runID); - $testtaskID = $this->dao->select('task')->from(TABLE_TESTRUN)->where('id')->eq($runID)->fetch('task', false); + $testtaskID = $this->dao->select('task')->from(TABLE_TESTRUN)->where('id')->eq($runID)->fetch('task'); $testtask = $this->dao->select('build, product')->from(TABLE_TESTTASK)->where('id')->eq($testtaskID)->fetch(); $builds = $this->loadModel('build')->getProductBuildPairs($testtask->product); $this->view->build = isset($builds[$testtask->build]) ? $builds[$testtask->build] : ''; diff --git a/module/testtask/model.php b/module/testtask/model.php index 410684a20e..5e33d463a4 100644 --- a/module/testtask/model.php +++ b/module/testtask/model.php @@ -230,7 +230,7 @@ class testtaskModel extends model ->beginIF($moduleID)->andWhere('t2.module')->in($moduleID)->fi() ->orderBy($orderBy) ->page($pager) - ->fetchAll('', false); + ->fetchAll(); } /** diff --git a/module/todo/control.php b/module/todo/control.php index d80cfff595..f25d363ffc 100644 --- a/module/todo/control.php +++ b/module/todo/control.php @@ -388,7 +388,6 @@ class todo extends control if($todo->private == 1) $todo->desc = $this->lang->todo->thisIsPrivate; /* drop some field that is not needed. */ - unset($todo->company); unset($todo->idvalue); unset($todo->private); } diff --git a/module/upgrade/model.php b/module/upgrade/model.php index af85444314..14f85b3048 100644 --- a/module/upgrade/model.php +++ b/module/upgrade/model.php @@ -147,23 +147,6 @@ class upgradeModel extends model */ public function updateCompany() { - /* Get user defined constants. */ - $constants = get_defined_constants(true); - $userConstants = $constants['user']; - - /* Update tables. */ - foreach($userConstants as $key => $value) - { - if(strpos($key, 'TABLE') === false) continue; - if($key == 'TABLE_COMPANY') continue; - - $table = $value; - $result = $this->dbh->query("SHOW TABLES LIKE '$table'"); - if($result->rowCount() > 0) - { - $this->dbh->query("UPDATE $table SET company = '{$this->app->company->id}'"); - } - } } /** @@ -341,18 +324,18 @@ class upgradeModel extends model $task->lastEditedDate = $action->date; /* Update action type. */ - $this->dao->update(TABLE_ACTION)->set('action')->eq($action->action)->where('id')->eq($action->id)->exec(false); + $this->dao->update(TABLE_ACTION)->set('action')->eq($action->action)->where('id')->eq($action->id)->exec(); } } /* Update db. */ foreach($tasks as $task) { - $this->dao->update(TABLE_TASK)->data($task, false)->where('id')->eq($task->id)->exec(false); + $this->dao->update(TABLE_TASK)->data($task)->where('id')->eq($task->id)->exec(); } - $this->dao->update(TABLE_TASK)->set('assignedTo=openedBy, assignedDate = finishedDate')->where('status')->eq('done')->exec(false); - $this->dao->update(TABLE_TASK)->set('assignedTo=openedBy, assignedDate = canceledDate')->where('status')->eq('cancel')->exec(false); + $this->dao->update(TABLE_TASK)->set('assignedTo=openedBy, assignedDate = finishedDate')->where('status')->eq('done')->exec(); + $this->dao->update(TABLE_TASK)->set('assignedTo=openedBy, assignedDate = canceledDate')->where('status')->eq('cancel')->exec(); /* Update action name. */ } @@ -430,9 +413,8 @@ class upgradeModel extends model ->where('`group`')->eq($group->group) ->andWhere('module')->eq('task') ->andWhere('method')->eq('recordEstimate') - ->exec(false); + ->exec(); $this->dao->insert(TABLE_GROUPPRIV) - ->set('company')->eq($group->company) ->set('`group`')->eq($group->group) ->set('module')->eq('task') ->set('method')->eq('recordEstimate') @@ -442,9 +424,8 @@ class upgradeModel extends model ->where('`group`')->eq($group->group) ->andWhere('module')->eq('task') ->andWhere('method')->eq('editEstimate') - ->exec(false); + ->exec(); $this->dao->insert(TABLE_GROUPPRIV) - ->set('company')->eq($group->company) ->set('`group`')->eq($group->group) ->set('module')->eq('task') ->set('method')->eq('editEstimate') @@ -454,9 +435,8 @@ class upgradeModel extends model ->where('`group`')->eq($group->group) ->andWhere('module')->eq('task') ->andWhere('method')->eq('deleteEstimate') - ->exec(false); + ->exec(); $this->dao->insert(TABLE_GROUPPRIV) - ->set('company')->eq($group->company) ->set('`group`')->eq($group->group) ->set('module')->eq('task') ->set('method')->eq('deleteEstimate') @@ -554,8 +534,8 @@ class upgradeModel extends model */ public function deletePatch() { - $this->dao->delete()->from(TABLE_EXTENSION)->where('type')->eq('patch')->exec(false); - $this->dao->delete()->from(TABLE_EXTENSION)->where('code')->in('zentaopatch,patch')->exec(false); + $this->dao->delete()->from(TABLE_EXTENSION)->where('type')->eq('patch')->exec(); + $this->dao->delete()->from(TABLE_EXTENSION)->where('code')->in('zentaopatch,patch')->exec(); } /** @@ -623,7 +603,7 @@ class upgradeModel extends model public function processFlow() { /* First delete all flow records. */ - $this->setting->deleteItems('company=0,1&owner=system&module=common§ion=global&key=flow'); + $this->setting->deleteItems('owner=system&module=common§ion=global&key=flow'); /* Search the extension table to check zentaotest, zentaotask, zentaostory exists or not. */ $flow = 'full'; @@ -653,7 +633,6 @@ class upgradeModel extends model foreach($oldPriv as $item) { $this->dao->insert(TABLE_GROUPPRIV) - ->set('company')->eq($item->company) ->set('module')->eq('company') ->set('method')->eq('view') ->set('`group`')->eq($item->group) @@ -668,7 +647,6 @@ class upgradeModel extends model foreach($oldPriv as $item) { $this->dao->insert(TABLE_GROUPPRIV) - ->set('company')->eq($item->company) ->set('module')->eq('todo') ->set('method')->eq('batchFinish') ->set('`group`')->eq($item->group) diff --git a/module/user/control.php b/module/user/control.php index e2f306af7b..a647890d60 100644 --- a/module/user/control.php +++ b/module/user/control.php @@ -500,7 +500,7 @@ class user extends control $this->view->user = $user; $this->view->depts = $this->dept->getOptionMenu(); $this->view->userGroups = implode(',', array_keys($userGroups)); - $this->view->groups = $this->loadModel('group')->getPairs($this->app->company->id); + $this->view->groups = $this->loadModel('group')->getPairs(); $this->display(); } diff --git a/module/user/model.php b/module/user/model.php index 0ec6c030de..589f5e7d00 100644 --- a/module/user/model.php +++ b/module/user/model.php @@ -335,7 +335,7 @@ class userModel extends model if(strpos($this->app->company->admins, ',' . $oldUser->account . ',') !== false) { $admins = str_replace(',' . $oldUser->account . ',', ',' . $this->post->account . ',', $this->app->company->admins); - $this->dao->update(TABLE_COMPANY)->set('admins')->eq($admins)->where('id')->eq($this->app->company->id)->exec(false); + $this->dao->update(TABLE_COMPANY)->set('admins')->eq($admins)->where('id')->eq($this->app->company->id)->exec(); if(!dao::isError()) $this->app->user->account = $this->post->account; } } @@ -396,7 +396,7 @@ class userModel extends model if(strpos($this->app->company->admins, ',' . $oldAccount . ',') !== false) { $admins = str_replace(',' . $oldAccount . ',', ',' . $user['account'] . ',', $this->app->company->admins); - $this->dao->update(TABLE_COMPANY)->set('admins')->eq($admins)->where('id')->eq($this->app->company->id)->exec(false); + $this->dao->update(TABLE_COMPANY)->set('admins')->eq($admins)->where('id')->eq($this->app->company->id)->exec(); } if(!dao::isError() and $this->app->user->account == $oldAccount) $this->app->user->account = $users['account']; } @@ -641,7 +641,7 @@ class userModel extends model $locked = date('Y-m-d H:i:s', mktime()); $failTimes = 0; } - $this->dao->update(TABLE_USER)->set('fails')->eq($failTimes)->set('locked')->eq($locked)->where('account')->eq($account)->exec(false); + $this->dao->update(TABLE_USER)->set('fails')->eq($failTimes)->set('locked')->eq($locked)->where('account')->eq($account)->exec(); return $fails; } @@ -668,7 +668,7 @@ class userModel extends model */ public function cleanLocked($account) { - $this->dao->update(TABLE_USER)->set('fails')->eq(0)->set('locked')->eq('0000-00-00 00:00:00')->where('account')->eq($account)->exec(false); + $this->dao->update(TABLE_USER)->set('fails')->eq(0)->set('locked')->eq('0000-00-00 00:00:00')->where('account')->eq($account)->exec(); } /** diff --git a/module/user/view/profile.html.php b/module/user/view/profile.html.php index 6cb437e4de..05cdeaa38d 100644 --- a/module/user/view/profile.html.php +++ b/module/user/view/profile.html.php @@ -16,7 +16,7 @@ diff --git a/module/webapp/model.php b/module/webapp/model.php index 7bfd7d9eae..68a61edcf9 100644 --- a/module/webapp/model.php +++ b/module/webapp/model.php @@ -256,7 +256,7 @@ class webappModel extends model $data = fixer::input('post')->remove('files,customWidth,customHeight')->get(); if($data->size == 'custom') $data->size = (float)$this->post->customWidth . 'x' . (float)$this->post->customHeight; - $this->dao->update(TABLE_WEBAPP)->data($data)->where('id')->eq($webappID)->check('url', 'unique', "id != $webappID", false)->exec(); + $this->dao->update(TABLE_WEBAPP)->data($data)->where('id')->eq($webappID)->check('url', 'unique', "id != $webappID")->exec(); if(!dao::isError()) {
user->profile;?>
-
createLink('user', 'edit', "userID=$user->id&from=company"), $lang->user->editProfile); ?>
+
createLink('user', 'edit', "userID=$user->id"), $lang->user->editProfile); ?>
user->dept;?>