* finish task #2003.

This commit is contained in:
wangyidong
2014-08-18 07:14:09 +00:00
parent f5c3728f53
commit ddc3fd28ea
11 changed files with 143 additions and 24 deletions

View File

@@ -739,4 +739,47 @@ class commonModel extends model
$this->session->set($objectType . 'OrderBy', '');
}
}
/**
* Check repeat for story,task,bug,case,doc.
*
* @param string $type
* @param string $mode
* @param string $title
* @param string $condition
* @access public
* @return bool|array
*/
public function checkRepeat($type, $mode = 'check', $title = '', $condition = '')
{
$table = $this->config->objectTables[$type];
$field = $type == 'task' ? 'name' : 'title';
$date = date(DT_DATETIME1, time() - 1 * 60);
if($mode == 'check' and empty($title)) return false;
if($mode == 'check')
{
$repeatObject = $this->dao->select('*')->from($table)
->where('deleted')->eq(0)
->andWhere($field)->eq($title)
->beginIF($type == 'doc')->andWhere('addedDate')->ge($date)->fi()
->beginIF($type != 'doc')->andWhere('openedDate')->ge($date)->fi()
->beginIF($condition)->andWhere($condition)->fi()
->fetch();
if($repeatObject) return $repeatObject->id;
return false;
}
elseif($mode == 'get')
{
return $this->dao->select("id,$field")->from($table)
->where('deleted')->eq(0)
->beginIF($type == 'doc')->andWhere('addedDate')->ge($date)->fi()
->beginIF($type != 'doc')->andWhere('openedDate')->ge($date)->fi()
->beginIF($condition)->andWhere($condition)->fi()
->fetchPairs();
}
return false;
}
}