* refactory.

* mv objectTables to config/config.php from action/config.php.
This commit is contained in:
wangyidong
2013-01-08 08:03:02 +00:00
parent 848f20cd1f
commit 8ea3c3b1db
4 changed files with 23 additions and 31 deletions

View File

@@ -121,3 +121,18 @@ define('TABLE_FILE', '`' . $config->db->prefix . 'file`');
define('TABLE_HISTORY', '`' . $config->db->prefix . 'history`');
define('TABLE_EXTENSION', '`' . $config->db->prefix . 'extension`');
define('TABLE_WEBAPP', '`' . $config->db->prefix . 'webapp`');
$config->objectTables['product'] = TABLE_PRODUCT;
$config->objectTables['story'] = TABLE_STORY;
$config->objectTables['productplan'] = TABLE_PRODUCTPLAN;
$config->objectTables['release'] = TABLE_RELEASE;
$config->objectTables['project'] = TABLE_PROJECT;
$config->objectTables['task'] = TABLE_TASK;
$config->objectTables['build'] = TABLE_BUILD;
$config->objectTables['bug'] = TABLE_BUG;
$config->objectTables['case'] = TABLE_CASE;
$config->objectTables['testtask'] = TABLE_TESTTASK;
$config->objectTables['user'] = TABLE_USER;
$config->objectTables['doc'] = TABLE_DOC;
$config->objectTables['doclib'] = TABLE_DOCLIB;
$config->objectTables['todo'] = TABLE_TODO;

View File

@@ -1,19 +1,4 @@
<?php
$config->action->objectTables['product'] = TABLE_PRODUCT;
$config->action->objectTables['story'] = TABLE_STORY;
$config->action->objectTables['productplan'] = TABLE_PRODUCTPLAN;
$config->action->objectTables['release'] = TABLE_RELEASE;
$config->action->objectTables['project'] = TABLE_PROJECT;
$config->action->objectTables['task'] = TABLE_TASK;
$config->action->objectTables['build'] = TABLE_BUILD;
$config->action->objectTables['bug'] = TABLE_BUG;
$config->action->objectTables['case'] = TABLE_CASE;
$config->action->objectTables['testtask'] = TABLE_TESTTASK;
$config->action->objectTables['user'] = TABLE_USER;
$config->action->objectTables['doc'] = TABLE_DOC;
$config->action->objectTables['doclib'] = TABLE_DOCLIB;
$config->action->objectTables['todo'] = TABLE_TODO;
$config->action->objectNameFields['product'] = 'name';
$config->action->objectNameFields['story'] = 'title';
$config->action->objectNameFields['productplan'] = 'title';

View File

@@ -42,7 +42,7 @@ class actionModel extends model
$action->extra = $extra;
/* Get product and project for this object. */
$productAndProject = $this->getProductAndProject($objectType, $objectID);
$productAndProject = $this->getProductAndProject($action->objectType, $objectID);
$action->product = $productAndProject['product'];
$action->project = $productAndProject['project'];
@@ -119,7 +119,6 @@ class actionModel extends model
*/
public function getProductAndProject($objectType, $objectID)
{
$objectType = strtolower($objectType);
$emptyRecord = array('product' => ',0,', 'project' => 0);
/* If objectType is product or project, return the objectID. */
@@ -134,7 +133,7 @@ class actionModel extends model
/* Only process these object types. */
if(strpos('story, productplan, release, task, build. bug, case, testtask, doc', $objectType) !== false)
{
if(!isset($this->config->action->objectTables[$objectType])) return $emptyRecord;
if(!isset($this->config->objectTables[$objectType])) return $emptyRecord;
/* Set fields to fetch. */
if(strpos('story, productplan, case', $objectType) !== false) $fields = 'product';
@@ -142,7 +141,7 @@ class actionModel extends model
if($objectType == 'release') $fields = 'product, build';
if($objectType == 'task') $fields = 'project, story';
$record = $this->dao->select($fields)->from($this->config->action->objectTables[$objectType])->where('id')->eq($objectID)->fetch();
$record = $this->dao->select($fields)->from($this->config->objectTables[$objectType])->where('id')->eq($objectID)->fetch();
/* Process story, release and task. */
if($objectType == 'story') $record->project = $this->dao->select('project')->from(TABLE_PROJECTSTORY)->where('story')->eq($objectID)->fetch('project');
@@ -236,7 +235,7 @@ class actionModel extends model
foreach($typeTrashes as $objectType => $objectIds)
{
$objectIds = array_unique($objectIds);
$table = $this->config->action->objectTables[$objectType];
$table = $this->config->objectTables[$objectType];
$field = $this->config->action->objectNameFields[$objectType];
$objectNames[$objectType] = $this->dao->select("id, $field AS name")->from($table)->where('id')->in($objectIds)->fetchPairs();
}
@@ -471,10 +470,10 @@ class actionModel extends model
foreach($actions as $object) $objectTypes[$object->objectType][] = $object->objectID;
foreach($objectTypes as $objectType => $objectIds)
{
if(!isset($this->config->action->objectTables[$objectType])) continue; // If no defination for this type, omit it.
if(!isset($this->config->objectTables[$objectType])) continue; // If no defination for this type, omit it.
$objectIds = array_unique($objectIds);
$table = $this->config->action->objectTables[$objectType];
$table = $this->config->objectTables[$objectType];
$field = $this->config->action->objectNameFields[$objectType];
if($table != '`zt_todo`')
{

View File

@@ -491,15 +491,8 @@ class commonModel extends model
{
$preAndNextObject = new stdClass();
switch($type)
{
case 'story' : $table = TABLE_STORY; break;
case 'task' : $table = TABLE_TASK; break;
case 'bug' : $table = TABLE_BUG; break;
case 'testcase' : $table = TABLE_CASE; break;
case 'doc' : $table = TABLE_DOC; break;
default : return $preAndNextObject;
}
if(strpos('story, task, bug, testcase, doc', $type) === false) return $preAndNextObject;
$table = $this->config->objectTables[$type];
$typeIDs = $type . 'IDs';
if($this->session->$typeIDs and strpos($this->session->$typeIDs, ',' . $objectID . ',') !== false)