This commit is contained in:
reneeteng
2020-03-20 23:38:59 +08:00
16 changed files with 178 additions and 43 deletions
+1
View File
@@ -66,6 +66,7 @@ zentaoxx:
cp -r xuan/xxb/module/client zentaoxx/module/
cp -r xuan/xxb/module/license zentaoxx/module/
cp -r xuan/xxb/module/owt zentaoxx/module/
cp xuan/xxb/apischeme.json zentaoxx/
mkdir -p zentaoxx/module/common/view
cp -r xuan/xxb/module/common/view/header.modal.html.php zentaoxx/module/common/view
cp -r xuan/xxb/module/common/view/marked.html.php zentaoxx/module/common/view
+1 -1
View File
@@ -1378,7 +1378,7 @@ class baseRouter
if(empty($extFiles) and empty($hookFiles)) return $mainModelFile;
/* 计算合并之后的modelFile路径。Compute the merged model file path. */
$extModelPrefix = ($siteExtended and !empty($this->siteCode)) ? $this->siteCode{0} . DS . $this->siteCode : '';
$extModelPrefix = ($siteExtended and !empty($this->siteCode)) ? $this->siteCode[0] . DS . $this->siteCode : '';
$mergedModelDir = $this->getTmpRoot() . 'model' . DS . ($extModelPrefix ? $extModelPrefix . DS : '');
$mergedModelFile = $mergedModelDir . $moduleName . '.php';
if(!is_dir($mergedModelDir)) mkdir($mergedModelDir, 0755, true);
@@ -45,7 +45,7 @@ class HTMLPurifier_ChildDef_Custom extends HTMLPurifier_ChildDef
protected function _compileRegex()
{
$raw = str_replace(' ', '', $this->dtd_regex);
if ($raw{0} != '(') {
if ($raw[0] != '(') {
$raw = "($raw)";
}
$el = '[#a-zA-Z0-9_.-]+';
@@ -75,7 +75,7 @@ class HTMLPurifier_TagTransform_Font extends HTMLPurifier_TagTransform
if (isset($attr['size'])) {
// normalize large numbers
if ($attr['size'] !== '') {
if ($attr['size']{0} == '+' || $attr['size']{0} == '-') {
if ($attr['size'][0] == '+' || $attr['size'][0] == '-') {
$size = (int)$attr['size'];
if ($size < -2) {
$attr['size'] = '-2';
+3 -3
View File
@@ -124,7 +124,7 @@ class GitRepo
$branches = array();
foreach($list as $localBranch)
{
if($localBranch{0} == '*') $localBranch = substr($localBranch, 1);
if($localBranch[0] == '*') $localBranch = substr($localBranch, 1);
$localBranch = trim($localBranch);
if(empty($localBranch))continue;
@@ -216,7 +216,7 @@ class GitRepo
foreach($list as $line)
{
if(empty($line)) continue;
if($line{0} == '^') $line = substr($line, 1);
if($line[0] == '^') $line = substr($line, 1);
preg_match('/^([0-9a-f]{39,40})\s.*\((\S+)\s+([\d-]+)\s(.*)\s(\d+)\)(.*)$/U', $line, $matches);
if(isset($matches[1]) and $matches[1] != $revision)
@@ -385,7 +385,7 @@ class GitRepo
$line = $lines[$i];
if(strpos($line, '\ No newline at end of file') === 0)continue;
$sign = empty($line) ? '' : $line{0};
$sign = empty($line) ? '' : $line[0];
if($sign == '-' and $newFile) $sign = '+';
$type = $sign != '-' ? $sign == '+' ? 'new' : 'all' : 'old';
if($sign == '-' || $sign == '+')
+1 -1
View File
@@ -447,7 +447,7 @@ class Subversion
$line = $lines[$i];
if(strpos($line, '\ No newline at end of file') === 0)continue;
$sign = empty($line) ? '' : $line{0};
$sign = empty($line) ? '' : $line[0];
$type = $sign != '-' ? $sign == '+' ? 'new' : 'all' : 'old';
if($sign == '-' || $sign == '+') $line = substr_replace($line, ' ', 1, 0);
+147 -20
View File
@@ -12,16 +12,16 @@
class zdb
{
/**
* dbh
*
* @var object
* dbh
*
* @var object
* @access public
*/
public $dbh;
/**
* Construct
*
* Construct
*
* @access public
* @return void
*/
@@ -33,33 +33,159 @@ class zdb
/**
* Get all tables.
*
*
* @param string $type if type is 'base', just get base table.
* @access public
* @return array
*/
public function getAllTables()
public function getAllTables($type = 'base')
{
global $config;
$allTables = array();
$stmt = $this->dbh->query("show full tables");
while($table = $stmt->fetch(PDO::FETCH_ASSOC))
while($table = $stmt->fetch(PDO::FETCH_ASSOC))
{
$tableType = strtolower($table['Table_type']);
if($tableType != 'base table') continue;
if($type == 'base' and $tableType != 'base table') continue;
$tableName = $table["Tables_in_{$config->db->name}"];
$allTables[$tableName] = 'table';
$allTables[$tableName] = $tableType == 'base table' ? 'table' : $tableType;
}
return $allTables;
}
/**
* Dump db.
*
* @param string $fileName
* @param array $tables
* Get table fields.
*
* @param string $table
* @access public
* @return array
*/
public function getTableFields($table)
{
try
{
$this->dbh->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
$sql = "DESC $table";
$rawFields = $this->dbh->query($sql)->fetchAll();
$this->dbh->setAttribute(PDO::ATTR_CASE, PDO::CASE_NATURAL);
}
catch (PDOException $e)
{
global $dao;
$dao->sqlError($e);
}
$fields = array();
foreach($rawFields as $field) $fields[$field->field] = $field;
return $fields;
}
/**
* Diff current table fields with a fields array.
*
* @param string $table
* @param array $fields
* @access public
* @return array
*/
public function diffTable($table, $fields)
{
$tableFields = $this->getTableFields($table);
$diff = array_udiff_assoc($fields, $tableFields,
function($a, $b)
{
return (array)$a == (array)$b ? 0 : 1;
}
);
return $diff;
}
/**
* Add a column to a table, or modify a existing column.
*
* @param string $table
* @param object $column
* @param boolean $add if true, add $column as a new column, otherwise modify a existing column to $column.
* @access public
* @return object
*/
public function updateColumn($table, $column, $add = true)
{
$return = new stdclass();
$return->result = true;
$return->error = '';
$query = "ALTER TABLE `$table` " . ($add ? 'ADD' : 'MODIFY COLUMN') . " `$column->field` $column->type" . ($column->null == 'NO' ? ' NOT NULL' : '') . (is_null($column->default) ? '' : " DEFAULT '$column->default'") . (empty($column->extra) ? '' : " $column->extra") . ';';
try
{
$this->dbh->exec($query);
return $return;
}
catch(PDOException $e)
{
$return->result = false;
$return->error = $e->getMessage();
$return->sql = $query;
return $return;
}
}
/**
* Create a table with fields.
*
* @param string $name
* @param array $fields
* @access public
* @return object
*/
public function createTable($name, $fields)
{
$return = new stdclass();
$return->result = true;
$return->error = '';
$createTableQuery = "CREATE TABLE `$name` (";
foreach($fields as $field)
{
$createColumnQuery = "`$field->field` $field->type" . ($field->null == 'NO' ? ' NOT NULL' : '') . (is_null($field->default) ? '' : " DEFAULT '$field->default'") . (empty($field->extra) ? '' : " $field->extra") . ", ";
if(!empty($field->key))
{
if($field->key === 'PRI') $createColumnQuery .= "PRIMARY KEY (`{$field->field}`), ";
if($field->key === 'MUL') $createColumnQuery .= "KEY `{$field->field}` (`{$field->field}`), ";
if($field->key === 'UNI') $createColumnQuery .= "UNIQUE KEY `{$field->field}` (`{$field->field}`), ";
}
$createTableQuery .= $createColumnQuery;
}
$createTableQuery = rtrim($createTableQuery, ', ');
$createTableQuery .= ") ENGINE=MyISAM DEFAULT CHARSET=utf8;";
try
{
$this->dbh->exec($createTableQuery);
return $return;
}
catch(PDOException $e)
{
$return->result = false;
$return->error = $e->getMessage();
$return->sql = $createTableQuery;
return $return;
}
}
/**
* Dump db.
*
* @param string $fileName
* @param array $tables
* @access public
* @return object
*/
@@ -139,10 +265,11 @@ class zdb
}
/**
* Import DB
*
* Import DB
*
* @param string $fileName
* @access public
* @return object;
* @return object
*/
public function import($fileName)
{
@@ -210,10 +337,10 @@ class zdb
/**
* Get schema SQL.
*
* @param string $table
*
* @param string $table
* @access public
* @return string
* @return object
*/
public function getSchemaSQL($table, $type = 'table')
{
+2 -2
View File
@@ -254,7 +254,7 @@ class commonModel extends model
{
echo '<li class="user-profile-item">';
echo "<a href='" . helper::createLink('my', 'profile') . "' class='" . (!empty($app->user->role) && isset($lang->user->roleList[$app->user->role]) ? '' : ' no-role') . "'>";
echo "<div class='avatar avatar bg-secondary avatar-circle'>" . strtoupper($app->user->account{0}) . "</div>\n";
echo "<div class='avatar avatar bg-secondary avatar-circle'>" . strtoupper($app->user->account[0]) . "</div>\n";
echo '<div class="user-profile-name">' . (empty($app->user->realname) ? $app->user->account : $app->user->realname) . '</div>';
if(isset($lang->user->roleList[$app->user->role])) echo '<div class="user-profile-role">' . $lang->user->roleList[$app->user->role] . '</div>';
echo '</a></li><li class="divider"></li>';
@@ -1766,7 +1766,7 @@ EOD;
{
$timestamp = $queryString['time'];
if(strlen($timestamp) > 10) $timestamp = substr($timestamp, 0, 10);
if(strlen($timestamp) != 10 or $timestamp{0} >= '4') $this->response('ERROR_TIMESTAMP');
if(strlen($timestamp) != 10 or $timestamp[0] >= '4') $this->response('ERROR_TIMESTAMP');
$result = $this->get->token == md5($entry->code . $entry->key . $queryString['time']);
if($result)
+1 -1
View File
@@ -22,7 +22,7 @@ $.initSidebar();
<div id="noticeBox"><?php echo $this->loadModel('score')->getNotice(); ?></div>
<script>
<?php if(!isset($config->global->browserNotice)):?>
browserNotice = <?php echo helper::jsonEncode($lang->browserNotice)?>;
browserNotice = <?php echo json_encode($lang->browserNotice)?>;
function ajaxIgnoreBrowser(){$.get(createLink('misc', 'ajaxIgnoreBrowser'));}
$(function(){showBrowserNotice()});
<?php endif;?>
+1 -1
View File
@@ -569,7 +569,7 @@ class fileModel extends model
while($line)
{
/* the cell has '"', the delimiter is '",'. */
if($line{0} == '"')
if($line[0] == '"')
{
$pos = strpos($line, '",');
if($pos === false)
+2 -2
View File
@@ -361,7 +361,7 @@ class gitModel extends model
chdir($repo->path);
exec("{$this->client} config core.quotepath false");
$subPath = substr($path, strlen($repo->path));
if($subPath{0} == '/' or $subPath{0} == '\\') $subPath = substr($subPath, 1);
if($subPath[0] == '/' or $subPath[0] == '\\') $subPath = substr($subPath, 1);
$encodings = explode(',', $this->config->git->encodings);
foreach($encodings as $encoding)
@@ -402,7 +402,7 @@ class gitModel extends model
putenv('LC_CTYPE=en_US.UTF-8');
$subPath = substr($path, strlen($repo->path));
if($subPath{0} == '/' or $subPath{0} == '\\') $subPath = substr($subPath, 1);
if($subPath[0] == '/' or $subPath[0] == '\\') $subPath = substr($subPath, 1);
$encodings = explode(',', $this->config->git->encodings);
foreach($encodings as $encoding)
+13 -6
View File
@@ -579,6 +579,7 @@ class taskModel extends model
$currentTask = !empty($task) ? $task : new stdclass();
if(!isset($currentTask->status)) $currentTask->status = $oldTask->status;
$currentTask->assignedTo = $oldTask->assignedTo;
if(!empty($this->post->assignedTo))
{
$currentTask->assignedTo = $this->post->assignedTo;
@@ -1155,8 +1156,8 @@ class taskModel extends model
$estimate = new stdclass();
$estimate->date = zget($task, 'realStarted', date(DT_DATE1));
$estimate->task = $taskID;
$estimate->consumed = zget($task, 'consumed', 0);
$estimate->left = zget($task, 'left', 0);
$estimate->consumed = zget($_POST, 'consumed', 0);
$estimate->left = zget($_POST, 'left', 0);
$estimate->work = zget($task, 'work', '');
$estimate->account = $this->app->user->account;
$estimate->consumed = $estimate->consumed - $oldTask->consumed;
@@ -1378,14 +1379,20 @@ class taskModel extends model
}
$estimate = new stdclass();
$estimate->date = zget($task, 'finishedDate', date(DT_DATE1));
$estimate->date = zget($_POST, 'finishedDate', date(DT_DATE1));
$estimate->task = $taskID;
$estimate->consumed = zget($task, 'consumed', 0);
$estimate->left = zget($task, 'left', 0);
$estimate->left = 0;
$estimate->work = zget($task, 'work', '');
$estimate->account = $this->app->user->account;
$estimate->consumed = $consumed;
if(!empty($oldTask->team))
{
foreach($oldTask->team as $teamAccount => $team)
{
if($teamAccount == $this->app->user->account) continue;
$estimate->left += $team->left;
}
}
if($estimate->consumed) $this->addTaskEstimate($estimate);
if(!empty($oldTask->team))
+1 -1
View File
@@ -1668,7 +1668,7 @@ class treeModel extends model
$createdVersion = $this->dao->select($versionField)->from($table)->where('id')->eq($rootID)->fetch($versionField);
if($createdVersion)
{
if(is_numeric($createdVersion{0}) and version_compare($createdVersion, '4.1', '<=')) return false;
if(is_numeric($createdVersion[0]) and version_compare($createdVersion, '4.1', '<=')) return false;
return true;
}
}
+1 -1
View File
@@ -43,7 +43,7 @@ if(isset($_GET['mode']) and $_GET['mode'] == 'getconfig') die(helper::removeUTF8
/* Check for need upgrade. */
$config->installedVersion = $common->loadModel('setting')->getVersion();
if(((is_numeric($config->version{0}) and is_numeric($config->installedVersion{0})) or $config->version{0} == $config->installedVersion{0}) and version_compare($config->version, $config->installedVersion, '>')) die(header('location: upgrade.php'));
if(((is_numeric($config->version[0]) and is_numeric($config->installedVersion[0])) or $config->version[0] == $config->installedVersion[0]) and version_compare($config->version, $config->installedVersion, '>')) die(header('location: upgrade.php'));
/* Remove install.php and upgrade.php. */
if(file_exists('install.php') or file_exists('upgrade.php'))
+1 -1
View File
@@ -56,7 +56,7 @@ $app->setDebug();
/* Check the installed version is the latest or not. */
$config->installedVersion = $common->loadModel('setting')->getVersion();
if(($config->version{0} == $config->installedVersion{0} or (is_numeric($config->version{0}) and is_numeric($config->installedVersion{0}))) and version_compare($config->version, $config->installedVersion) <= 0) die(header('location: index.php'));
if(($config->version[0] == $config->installedVersion[0] or (is_numeric($config->version[0]) and is_numeric($config->installedVersion[0]))) and version_compare($config->version, $config->installedVersion) <= 0) die(header('location: index.php'));
/* Run it. */
$app->parseRequest();
@@ -19,7 +19,7 @@ class xuanxuanMessage extends messageModel
$server = $this->loadModel('im')->getServer('zentao');
$onlybody = isset($_GET['onlybody']) ? $_GET['onlybody'] : '';
unset($_GET['onlybody']);
$url = $server . helper::createLink($objectType, 'view', "id=$objectID", 'xhtml');
$url = $server . helper::createLink($objectType, 'view', "id=$objectID", 'html');
$url = "xxc:openInApp/zentao-integrated/" . urlencode($url);
$target = '';